Gravv
/Docs
Search docs or ask a question⌘K
DocsAgent
ChangelogTry sandbox
Guides Get Started Authentication

Authentication

How to send your secret API key with every request, and where to find your keys and webhook settings in the Dashboard.

4 min read

This page shows how to authenticate API requests with your secret API key and how to set up webhooks in the Dashboard.

API keys

Every request to the Gravv API needs your secret API key in the Api-Key header:

text
Api-Key: grvSec_<sandbox|live>_…

You have one secret key for each environment. A key that starts with grvSec_sandbox_ reaches sandbox, and a live key reaches live. The Dashboard also shows a Public Key, but no API endpoint uses it.

Your API key identifies your business and environment. Gravv reads the business from the key, so there is no tenant header to send. Gravv ignores any tenant header you send.

Keep your API keys secret. Don't put them in GitHub repositories, client-side code, or anywhere other people can read them. Send all requests over HTTPS.

Obtain and use your API keys

To get your API key:

1.
Sign in to your Gravv Dashboard with your registered business email address.
2.
Turn on Sandbox mode for testing, or Production for live.
3.
Click Manage in the side navigation.
4.
Click Configure under the Manage section.
5.
Click API keys, then click the copy button under Secret Key to copy your Secret Key.
6.
Use the copied Secret Key as the Api-Key in your request header:
sample request
curl -X POST https://api.gravv.xyz/v1/customers \
-H "Api-Key: <API_KEY>" \
-H "Idempotency-Key: <a new UUID for this request>" \
-H "Content-Type: application/json" \
-d '{
"first_name": "Jane",
"last_name": "Doe",
"middle_name": "Sample",
"email": "jane.doe@example.com",
"phone": "+2348031230101",
"type": "individual",
"gender": "female",
"date_of_birth": "1992-04-16",
"address": {
"address_line1": "Same Global Housing Estate",
"city": "Lokogoma",
"country": "NG",
"postal_code": "900107",
"state": "NG-FC"
}
}'

Replacing a key

When you create a new secret key for an environment, Gravv deletes the previous key for that environment. Update every system that uses the old key at the same time. A deleted key can keep working for up to 2 minutes, because Gravv caches key checks for that long. A new key works at once.

Authentication errors

A request that fails authentication returns HTTP 401 with a message in error:

MessageCause
Invalid token!The key is unknown, deleted or malformed
Invalid Api Key header. Api-Key is required!No Api-Key header, on an endpoint that accepts only API keys
Invalid Authorization header. Bearer token or Api-Key is required!No Api-Key header, on an endpoint that also serves the Dashboard
401 response
{
"data": null,
"error": "Invalid token!"
}

If your key is limited to certain permissions, a request outside them returns HTTP 403 with the permissions it needs:

403 response
{
"data": null,
"error": {
"reason": "forbidden",
"required_any": [
"transfer:initiate"
]
}
}

A key can carry only permissions that the person who creates it holds. Owners, admins and developers hold payee:delete, which deleting an external account needs. A developer picks it up at their next sign-in. Only owners and admins hold payee:approve.

Webhooks

You set up webhooks in the Dashboard. There is no API for it. Each environment takes up to 2 endpoints, and each endpoint receives the event types you pick for it, or every event type when you pick none.

Gravv has two Dashboards while the new one rolls out. The steps differ.

In the new Dashboard:

1.
Follow steps 1 through 4 in Obtain and use your API keys, with the environment you want selected.
2.
Open Configure, and under webhooks click Add endpoint.
3.
Enter your URL. It must be a public https URL. Add a description, and pick the events to send, or leave them all.
4.
Save, and copy the signing secret it shows. It starts with whsec_. You need the whole value, whsec_ included, to verify signatures.
5.
Click Send test event to check that your server answers.

To change a secret, click Roll secret and choose to keep the old one for 24 hours or stop it now. See Roll a secret. When Gravv turns an endpoint off, fix your server, then click Turn back on.

In the current Dashboard:

1.
Follow steps 1 through 4 in Obtain and use your API keys, with the environment you want selected.
2.
Click Webhooks.
3.
Click Create Webhook to open the form.
4.
Enter your webhook endpoint in the Webhook URL field. It must be a public https URL.
5.
Click Generate to create your webhook secret. It starts with whsec_. Save it. You need the whole value, whsec_ included, to verify signatures.

The current Dashboard shows one endpoint per environment. Generating a new secret there rolls it and keeps the old one for 24 hours. To stop a leaked secret at once, use the new Dashboard.

Sandbox and live each have their own endpoints, and each endpoint has its own secret. A change can take up to 5 minutes to apply.

Was this page helpful? Yes No