Guides
Authentication
Exchange clientId and clientSecret for a JWT and send it as a Bearer token on every call.
Every API call needs a valid JWT in the Authorization header. You get the token with the clientId and clientSecret of your Mimicr sandbox.
Where the credentials are
The credentials show up in the console (Trace Finance, Overview) and in the control API:
curl --url https://api.mimicr.dev/v1/trace \ --header 'Authorization: Bearer mk_...'
credentials.client_id and credentials.client_secret replace the credentials Trace hands out during onboarding. The same clientSecret signs the webhooks (see Verify the signature).
Get a token
curl --request POST \
--url https://trace.mimicr.dev/v1/oauth/client/token \
--header 'Content-Type: application/json' \
--data '{
"clientId": "<client_id>",
"clientSecret": "<client_secret>"
}'{
"accessToken": "eyJhbGciOiJSUzI1NiIs...",
"tokenType": "Bearer",
"expiresIn": 82800
}The body is JSON (not application/x-www-form-urlencoded) and the endpoint does not require X-Idempotency-Key. Reference: Get a token.
Use the token
curl --url https://trace.mimicr.dev/v1/accounts \ --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIs...'
The token carries the customer identity, so no other identification header is needed.
Lifecycle
Tokens are valid for 23 hours (82,800 seconds).
- Keep the token in memory once you have it.
- Before using it, check the JWT
expclaim. - Renew it before it expires instead of waiting for a
401.
Do not request a new token for every call. Reuse the same one until it is close to expiry.
In Mimicr the token is an RS256 JWT signed with your sandbox's RSA key. Its claims include sub and customer_id (the customer id), client_id, iss, iat and exp. Expiry follows the sandbox clock: if you move the clock forward by a day, the current token expires, which is handy to test renewal (see Sandbox control).
Errors
| Status | code | When |
|---|---|---|
| 400 | INVALID_DATA (REQUIRED) | clientId or clientSecret missing from the body |
| 401 | INVALID_CREDENTIALS | Unknown clientId or wrong clientSecret |
| 401 | INVALID_ACCESS_TOKEN | Missing, malformed or forged token |
| 401 | EXPIRED_ACCESS_TOKEN | Token whose exp is in the past |
{
"code": "INVALID_CREDENTIALS",
"message": "Invalid client credentials",
"details": {}
}INVALID_CREDENTIALS is Mimicr's choice: Trace does not document the wrong-credentials error.
Related
- Environment: hosts and what differs between Trace and Mimicr.
- Quickstart: from activation to the first deposit.