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.
- 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 the dependencies:
go get "github.com/approveapi/approveapi-go"
import "github.com/approveapi/approveapi-go"
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 := true
prompt, _, err := client.ApproveApi.CreatePrompt(
approveapi.CreatePromptRequest {
User: "[email protected]",
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,
},
)
if err != nil {
fmt.Printf("%#v\n", err)
return
}
if prompt.Answer != nil {
if prompt.Answer.Result {
fmt.Println("Request approved")
} else {
fmt.Println("Request rejected")
}
} else {
fmt.Println("No response yet")
}
Full documentation is available here: approveapi.com/docs.