Method | Difficulty | Description |
---|---|---|
Use an Axios request client | Easy | Use an Axios client with a pre-configured interceptor that automatically handles authentication for all requests. |
Generate your authorization headers | Intermediate | Generate authentication headers and apply them to your preferred HTTP client. |
Generate a JWT | Advanced | Generate a JWT token, manually create your authentication headers, and apply them to your preferred HTTP client. |
Authorization
header to authenticate REST API requests to the CDP APIs using the HTTP request library of your choice.
Step 1: Install the required package:
Authorization
header of your HTTP request:
Authorization
headerContent-Type
headerParameter | Required | Description |
---|---|---|
apiKeyId | true | The unique identifier for your API key. Supported formats are: - xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - organizations/{orgId}/apiKeys/{keyId} |
apiKeySecret | true | Your API key secret. Supported formats are: - Edwards key (Ed25519): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx== - Elliptic Curve key (ES256): -----BEGIN EC PRIVATE KEY-----\n...\n...\n...==\n-----END EC PRIVATE KEY-----\n |
requestMethod | true* | The HTTP method for the API request you’re authenticating (ie, GET , POST , PUT , DELETE ). Can be null for JWTs intended for websocket connections. |
requestHost | true* | The API host you’re calling (ie, api.cdp.coinbase.com ). Can be null for JWTs intended for websocket connections. |
requestPath | true* | The path of the specific API endpoint you’re calling (ie, /platform/v1/wallets ). Can be null for JWTs intended for websocket connections. |
requestBody | false | Optional request body data. |
expiresIn | false | The JWT expiration time in seconds. After this time, the JWT will no longer be valid, and a new one must be generated. Defaults to 120 (ie, 2 minutes) if not specified. |
requestMethod
, requestHost
, and requestPath
) must be provided for REST API requests, or all three must be null
for JWTs intended for websocket connections.