Prima's REST API uses OAuth 2.0. Every request to the API must carry a JSON Web Token (JWT) obtained from your Prima server's token endpoint. This page covers setting up an API client, requesting and refreshing a token, and best practices for using it in an integration.
API clients are created and managed from your internal Prima website (typically something like 'https://prima.your-workplace-website.com'), under Admin → API Clients. Each client represents one integration and gets its own credentials, scopes, and token settings.
If an integration needs to stay authenticated over a long period without holding onto the client secret for every renewal, enable refresh tokens on the client:
offline_access scope, so a refresh token is returned alongside the access token.| Grant type | Use for |
|---|---|
client_credentials |
Recommended for server-to-server integrations. The client authenticates with its own ID and secret — no end-user login is involved. |
refresh_token |
Exchanging a refresh token for a new access token without repeating the original grant. |
password |
Resource owner password grant, tied to a specific Prima user login. Supported for backward compatibility; prefer client_credentials for new integrations. |
authorization_code |
Interactive applications where a person logs in and grants consent (e.g. a browser-based tool). Requires a Redirect URI configured on the client. |
Send a POST to your Prima server's token endpoint with the client's credentials:
POST https://your-prima-server/connect/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
client_id={ClientId}
client_secret={ClientSecret}
scope=api_read_all api_write_all
A successful response looks like:
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"expires_in": 3600,
"token_type": "Bearer"
}
Include offline_access in the requested scope (and enable refresh tokens on the client) to also receive a refresh_token in the response.
Before the access token expires, exchange the refresh token for a new one rather than repeating the original grant:
POST https://your-prima-server/connect/token
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token
client_id={ClientId}
client_secret={ClientSecret}
refresh_token={RefreshToken}
refresh_token that replaces the one just used. Save it — the old value stops working.
Include the access token on every API request as a bearer token:
GET https://your-prima-server/api/v2/Case
Authorization: Bearer eyJhbGciOiJSUzI1NiIs...
Access tokens are short-lived (one hour by default). Cache the token and reuse it for the duration of its lifetime instead of requesting a new one before every call — request a new one once it's close to expiring, or use the refresh token flow if it's configured.
client_credentials over password for server-to-server integrations — it doesn't tie the integration to an individual user's login.client_id and client_secret, and confirm the grant type being used is allowed on the client.scope may not include what the endpoint requires.An example .NET client is available at github.com/Fortelinea/PrimaRESTExampleClient. It demonstrates the resource owner password grant used by older (V1) integrations; new integrations should follow the client_credentials pattern described above instead.