Authentication
How to send your secret API key with every request, and where to find your keys and webhook settings in the Dashboard.
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:
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:
Sandbox mode for testing, or Production for live.Manage in the side navigation.Configure under the Manage section.API keys, then click the copy button under Secret Key to copy your Secret Key.Secret Key as the Api-Key in your request header: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:
| Message | Cause |
|---|---|
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 |
If your key is limited to certain permissions, a request outside them returns HTTP 403 with the permissions it needs:
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:
Configure, and under webhooks click Add endpoint.URL. It must be a public https URL. Add a description, and pick the events to send, or leave them all.whsec_. You need the whole value, whsec_ included, to verify signatures.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:
Webhooks.Create Webhook to open the form.Webhook URL field. It must be a public https URL.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.