Guides
Getting started

Authentication

Exchange clientId and clientSecret for a one-hour Bearer token.

Bloquo's server-to-server integration uses a single endpoint: POST /api/v1/auth/authenticateServer. It returns an RS256 JWT valid for 3600 seconds that represents the sandbox's root customer (an Institutional customer). There is no refresh token: when the token expires, request a new one.

Get the token

bash
curl -X POST https://bloquo.mimicr.dev/api/v1/auth/authenticateServer \
  -H "Content-Type: application/json" \
  -d '{"clientId": "acme-1a2b3c4d", "clientSecret": "3f74uiq7aM1hWOoJ..."}'
json
{
  "status": true,
  "result": {
    "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEwOGQxOTE0In0...",
    "expiresIn": 3600,
    "tokenType": "Bearer"
  },
  "message": null
}

The clientId and clientSecret are shown on the Bloquo overview in the console and in GET https://api.mimicr.dev/v1/bloquo (the credentials field). The console can also generate a new secret.

Use the token

Send the token on every other route:

bash
curl https://bloquo.mimicr.dev/api/v1/customer/me \
  -H "Authorization: Bearer <token>"
json
{
  "status": true,
  "statusCode": 200,
  "result": {
    "id": 1001,
    "typeId": 1,
    "name": "Acme Pagamentos Ltda",
    "parentId": null,
    "childEnabled": true,
    "maxChildDepth": 3,
    "status": "Active",
    "type": { "id": 1, "name": "Institutional" }
  },
  "message": null
}

Only authenticateServer and GET /api/v1/notification/webhook/public-key work without a token.

Errors

SituationHTTPmessage
Wrong clientId or clientSecret401NotAuthorizedException: Incorrect username or password.
No token, tampered or expired token401Unauthorized
{customerId} outside your hierarchy403Access denied.
{customerId} that doesn't exist400Customer with Id: '<id>' not found.

Bloquo doesn't document the 401 message for an invalid token; in Mimicr it is Unauthorized. The hierarchy rule (only the root customer and its descendants) is also Mimicr's reading of Bloquo's 403 examples.

Good practices

  • Keep the token and renew it a few minutes before expiresIn runs out, instead of authenticating on every call.
  • On 401 Unauthorized, authenticate again once and retry the call.
  • Expiry follows the sandbox clock: if you advance the clock by more than an hour (see Sandbox control), the current token expires and your integration has to renew it, exactly as in production.

Reference: Authenticate, Get current customer.