Authentication

You'll need to authenticate your requests to access any of the endpoints in the Composable API. In this guide, we'll look at how authentication works. We use two type of api keys: private and public.

The private key starts with "sk*" and the public key starts with "pk*". The private key is used to access the whole API, while the public key can only be used to execute interactions.

Using an API key

The way to authenticate with the Composable API is by using an API Key and a Project ID. To authenticate with curl, pass the API Key in the Authorization header:

Example request with bearer token

curl https://api.becomposable.com/v1/account/info \
  -H "Authorization: Bearer {api_key}" \

Always keep your key safe and reset it if you suspect it has been compromised.

Using the JavaScript/TypeScript SDK

If you use our official SDK, simply pass the API Key and Project ID when instantiating the client:

import { ComposableClient } from '@becomposable/client'
const client = new ComposableClient({
  apikey: '{api_key}',
})

// Now you can use the client to make requests
const info = await client.account.info()
const interactions = await client.interactions.list()

Using generated interaction classes

As we've explained in the quickstart guide you can access interactions through a strong typed typescript class which can be generated using the Composable CLI.

In that case you can pass the API Key as an option when instantiating the class. There is no need to pass the project ID since the generated class already knows it.

import { MyInteractionClass } from "./MyInteractionClass/index.js"

const interaction = new MyInteractionClass({
    apikey: "YOUR_API_KEY_HERE"
});

const run = await interaction.execute();

Was this page helpful?