Skip to main content
PrimeVault authenticates every external API request with an API-user key and a short-lived ES256 bearer token. Authentication is organization-scoped: credentials may access only the organization and permissions assigned to that API user.

Base URL

All endpoint paths are relative to this URL. The SDK signs the exact request URL and JSON body, adds the required headers, and maps HTTP failures to typed errors.
Create the client only in a trusted server environment. Never embed the API key or access private key in browser, mobile, or other distributed client code.

Generate a bearer token manually

Generate tokens manually only when you can’t use the official SDK to send the request. The token is request-bound: generate it from the relative URL path and the same body object that will be sent, then create a new token for the next request. The examples below accept either a PEM private key or a hex-encoded PKCS#8 DER private key. They intentionally use the DER-encoded ECDSA signature produced by the PrimeVault SDKs. Do not replace the signing step with a generic JWT helper unless it can emit that signature format.
For POST and PUT requests, construct the body once, pass that object to the token helper, and send the same object as JSON without mutating its keys or values between signing and transmission.

Required headers

Header names are case-insensitive at the HTTP layer, but use the spelling above in examples and diagnostics.

How request signing works

1
Build the relative request URL, excluding the scheme and host. The query string may be included; the verifier compares the path component.
2
Canonically serialize the request body with recursively sorted keys and compact JSON separators. Use an empty object for a request without a body.
3
Hash that canonical body with SHA-256 and create a short-lived payload containing iat, exp, urlPath, userId, body, and a unique jti.
4
Base64url-encode the header and payload, then sign header.payload with P-256 and SHA-256.
5
Send the resulting bearer token with the same API-user key in the Api-Key header.
Generate a new token for every request. Changing the path, body keys, or body values after token generation invalidates the request binding.

Credential and key safety

  • Store credentials in a secret manager or protected server environment variables.
  • Do not log bearer tokens, API keys, private keys, or complete bank-account details.
  • Rotate credentials immediately if they may have been exposed.
  • Keep server time synchronized. Tokens expire 120 seconds after they are issued, so clock skew causes 401 errors.
  • Restrict source IPs where appropriate; see API user IP whitelisting.
  • Use the least-privileged API user required by the integration.

Authentication failures

Do not treat a 403 as a token-refresh problem. Verify authorization and resource scope before retrying.

Setup references

Use Setting up API User to provision credentials and API user IP whitelisting to restrict allowed source addresses.