Skip to content

Repository files navigation

approveapi-go

GoDoc

Go API bindings for the ApproveAPI HTTP API.

ApproveAPI is a simple API to request a user's real-time approval on anything via email, sms + mobile push.

Features

  • Send Prompt
    • web redirect actions (i.e. magic links)
    • custom approve/reject buttons
    • metadata
    • long polling
  • Retrieve Prompt
  • Check Prompt status
  • Futures support
  • Webhook callbacks

Install

Install the dependencies:

go get "github.com/approveapi/approveapi-go"

Import:

import"github.com/approveapi/approveapi-go"

Getting Started

To get started, we create a client:

client:=approveapi.CreateClient("sk_test_yourapikeyhere")

Now we can make API calls. For example, let's send an approval prompt to confirm a financial transaction.

longPoll:=trueprompt, _, err:=client.ApproveApi.CreatePrompt(
approveapi.CreatePromptRequest {
User: "alice@approveapi.com",
Body: `A transfer of $1337.45 from acct 0294 to acct 1045 has been initiated. Do you want to authorize this transfer?`,
ApproveText: "Authorize",
RejectText: "Reject",
LongPoll: &longPoll,
},
)
iferr!=nil {
fmt.Printf("%#v\n", err)
return
}
ifprompt.Answer!=nil {
ifprompt.Answer.Result {
fmt.Println("Request approved")
} else {
fmt.Println("Request rejected")
}
} else {
fmt.Println("No response yet")
}

Documentation

Full documentation is available here: approveapi.com/docs.

About

A Go library for using ApproveAPI

Topics

Resources

Stars

16 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages