Authentication
Use an API key in your integration or authorize Raims CLI through your browser.
The Raims API accepts API keys and OAuth access from authorized applications. Use an API key in your integration's backend. To work in the terminal, you can also connect Raims CLI through your browser.
Both modes use the Authorization header with the Bearer scheme. The
credential and current access determine which requests can be executed.
| Your task | Credential | How the environment is selected |
|---|---|---|
| Backend integration | API key | The validated key determines the company and environment. |
| Interactive work in Raims CLI | OAuth access | The CLI sends the environment selected in the authorized profile. |
Before you start
Create an API key for the environment your application will use. See API keys to obtain and manage the credential.
To integrate with a client for your language, see the official SDKs. Each guide explains the installation channel and how to configure the credential on your backend.
Store the secret in a secrets vault or a protected environment variable, accessible only to the backend responsible for the integration.
Protect your API key
Do not expose the key in frontend applications, distributed apps, images, logs, or repositories. Send the secret only in the authentication header, never in the URL or request body.
OAuth in the CLI
Run raims login --profile pessoal --environment sandbox and complete
authorization in your browser. Check the account, environments, and permissions
before authorizing. The CLI protects the session through the operating system
and refreshes access while the connection remains valid. See
Configuration and profiles.
OAuth requests use an access token issued for the public API and set
X-Raims-Environment to Sandbox or Production. The CLI fills this header
from the selected environment. Selecting an environment does not grant access:
the environment and request must be authorized for the connection and the
person who approved it.
A token from an MCP connection does not authenticate direct public API calls.
Each connection uses access issued for its destination. To end the CLI's OAuth
access, run raims logout --profile pessoal.
Authentication header
When using an API key, configure your backend HTTP client with the following headers when sending a JSON body:
| Header | Usage |
|---|---|
Authorization | Required for authenticated requests. Use Bearer followed by a space and the complete key. |
Content-Type | Send application/json when the request has a JSON body. |
GET requests must use the parameters defined by the endpoint and have no
body. The key identifier, a masked secret, or a Dashboard login credential
cannot replace the API key.
Use HTTPS for API calls. Send the secret exactly as generated, without changing letters or adding characters.
First authenticated request with an API key
With a Sandbox key stored in the server's protected RAIMS_API_KEY variable,
this Bash example retrieves the first page of customers. The key needs
View customers. This request has no body and does not create a customer.
curl --request GET \
--url 'https://api.raims.com/v1/customers' \
--header "Authorization: Bearer $RAIMS_API_KEY" \
--header 'Accept: application/json'A successful HTTP 200 may return an empty page:
No customers found
{
"list": [],
"page": {
"page_size": 10,
"has_next": false,
"has_previous": false,
"next_after": null,
"previous_before": null
}
}list: [] means there are no customers for this query in the key's company
and environment. Authentication succeeded. If there are customers, list
contains their records. Use page to decide whether to fetch another page.
If the request fails, use the status and error.code to follow the
authentication checks below. Do not include the key
or full customer records in logs.
Sandbox and Production
The base URL is the same in both environments:
https://api.raims.comWith an API key, the key sent in the Authorization header determines the
environment and company. Do not send another header or a field in the URL
or body to choose the environment. X-Raims-Environment is used only with
OAuth; sending it with an API key does not change the request's environment.
| Environment | Key prefix | Usage |
|---|---|---|
| Sandbox | sk_test_ | Development and integration testing, with test data separate from Production data. |
| Production | sk_live_ | Requests with real effects on the account, sent by your backend. |
Validate the integration in Sandbox before using Production. To change environments, update the key configured in your backend and check the data and identifiers being sent. Changing the credential does not move a resource created in Sandbox into Production.
Key permissions
An API key must include the requested action in its permissions. Viewing, creating, updating, deleting, and other actions are selected separately. For example, allowing charge creation does not allow revoking charges or requesting refunds. Company and environment rules still apply.
403 API_KEY_PERMISSION_DENIED means the key does not authorize the operation.
Ask someone with Edit API keys to review access in
Integration / API keys / Edit permissions. Resending the same request
or changing the environment header does not add permissions.
See Key permissions to configure the integration's access.
IP restrictions
If the key has IP restrictions, requests must originate from an authorized address. Configure the public outbound IP of the server or infrastructure running your backend, including the authorized ranges when using CIDR.
See IP restrictions to configure the allowed ranges.
Authentication errors
A 401 Unauthorized response means the request could not be authenticated.
Check that:
AuthorizationcontainsBearer, a space, and the complete key;- the key is correct, with no extra characters or missing parts;
- the credential belongs to the intended company and environment;
- the key remains valid and has not been revoked or replaced through rotation.
After rotating a key, update your backend configuration with the new secret. The previous key no longer authenticates requests.
For an expired or revoked OAuth session, sign in again through the CLI. Also check that the request and environment are among the granted permissions. Refreshing the session does not add permissions to the original authorization.
A 403 Forbidden response may indicate a missing key permission, an IP restriction, an account
condition, or another authorization rule. A valid key does not allow a
request blocked by those conditions.
COMPANY_STATUS_RESTRICTED means the company's status prevents access.
Suspended companies or companies with a closed account cannot use the API
in either environment. A pending registration allows Sandbox only. The message
identifies the condition and directs you to Customer Service or to check
the registration in the Dashboard.
See HTTP response codes to interpret the status, code, and message returned by the API.