API endpoints require authentication to access. To interact with these resources, you must create an API key via the Coinbase Derivatives Command Center (DCC).
The CB-ACCESS-TIMESTAMP header MUST be number of seconds since Unix Epoch in UTC. Decimal values are not allowed. Make sure to use an integer.Your timestamp should be within 5 seconds of the API service time or your request is considered expired and will be rejected.
The CB-ACCESS-SIGN header is generated by creating an HMAC-SHA-256 using the secret key on the prehash string timestamp + method + requestPath + body (where + represents string concatenation) and Base64-encode the output.
timestamp is the same as the CB-ACCESS-TIMESTAMP header.
method should be UPPER CASE, e.g., GET or POST.
requestPath should only include the path of the API endpoint. Do NOT include the base URL or query parameters when creating the signature.Valid requestPath example to include in the string for hashing:
body is the request body string or omitted if there is no request body (typically for GET requests).
Remember to Base64-encode the digest output before sending in the header. That is, the secret should not be Base64 encoded when using HMAC-SHA-256 to sign the request, but the entire resulting message.
The following examples demonstrate how to sign a message by generating an HMAC signature, setting the headers, and making a GET request to the specified URL.