Authentication

Use API keys to authenticate your client requests when utilizing Circle APIs.

API keys are unique data strings used to authenticate a user and enable access to privileged operations on Circle APIs. All Circle APIs use API keys as the mechanism to authenticate client requests. Your API key should be kept confidential and secure at all times.

  • Authentication is required for all API requests; without it, the requests will fail.
  • All API requests must be made over HTTPS.
  • To obtain the API key, visit the “Developer” section in sandbox and click “get new API key.” Set the key in the Authorization header of the request you send from your backend server. Use the header format:
    Bearer YOUR_API_KEY.

API Authentication

Authorization: Bearer YOUR_API_KEY

API requests without authentication will fail. It is also important to note that all API requests must be made over HTTPS.

Testing Authentication

To verify that your API key is correctly set up, run the command below, which causes your code to hit a read endpoint (in this case, the configuration endpoint).

# Replace ${YOUR_API_KEY} with your API key
curl -H 'Accept: application/json' \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -X GET --url https://api-sandbox.circle.com/v1/configuration
/** 
 * See installation instructions at 
 * https://developers.circle.com/developer/docs/circle-sdk
 */
import { Circle, CircleEnvironments } from "@circle-fin/circle-sdk";

const circle = new Circle(
    '<your-api-key>',
    CircleEnvironments.sandbox
);

async function getAccountConfig() {
    const configResp = await circle.management.getAccountConfig();
    console.log(configResp.data);
}
getAccountConfig();

👍

Successful Response

{"data":{"payments":{"masterWalletId":"1234567890"}}}

❗️

Error Response

{"code":401,"message":"Malformed authorization. Are the credentials properly encoded?"}