> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rawchunks.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up API requests

> Use your Rawchunks session key to call the music API.

Create a session in [Rawchunks](https://app.rawchunks.space) through **SESSION**, following the [session walkthrough](/app/payments#start-a-session). Use that session's full token as the bearer credential for paid API calls.

All music requests go to `https://api.rawchunks.space`. The examples use Node.js 20 or later and native `fetch`.

## Request headers

| Header | Value |
| - | - |
| `Authorization` | `Bearer $SESSION_TOKEN` for paid calls. Use the complete session token, not its key ID. |
| `x-session-user-address` | The wallet address used to create your Rawchunks session. Send it for your projects, edits and saved voices. |
| `x-network-id` | Your session's network ID, such as `eip155:8453` for Base. |
| `Content-Type` | `application/json` for JSON bodies. Let the client set multipart upload boundaries. |

Use the same address in request fields such as `creatorAddress`, `creator` and `userAddress`. EVM identities are normalized to lowercase; Solana addresses are case-sensitive.

## Reuse the request headers

Define this small request helper in your integration. The following guides use `api` and `userAddress` from this block.

```javascript theme={null}
const userAddress = process.env.USER_ADDRESS;
const sessionHeaders = {
  Authorization: `Bearer ${process.env.SESSION_TOKEN}`,
  'x-session-user-address': userAddress,
  'x-network-id': process.env.NETWORK,
};

async function request(path, { method = 'GET', json, form, signal } = {}) {
  const response = await fetch('https://api.rawchunks.space' + path, {
    method, signal,
    headers: {
      ...sessionHeaders,
      ...(json === undefined ? {} : { 'Content-Type': 'application/json' }),
    },
    body: json === undefined ? form : JSON.stringify(json),
  });
  const body = await response.json();
  if (!response.ok) {
    const error = new Error(body?.error || `HTTP ${response.status}`);
    error.status = response.status;
    error.body = body;
    throw error;
  }
  return body;
}

const api = {
  request,
  get: path => request(path),
  post: (path, json) => request(path, { method: 'POST', json }),
  patch: (path, json) => request(path, { method: 'PATCH', json }),
  delete: path => request(path, { method: 'DELETE' }),
};

const options = await api.get('/api/options');
console.log(options.generation.modes);
```

Keep the token in your server's secret configuration. It authorizes spending within the session cap until expiration or revocation. Your product still needs its own user authentication.

## Check connectivity

```bash theme={null}
export RAWCHUNKS_API='https://api.rawchunks.space'
curl --fail-with-body "$RAWCHUNKS_API/api/options"
```

Endpoint examples also use `curl` and `jq`. Set `USER_ADDRESS`, `NETWORK`, `SESSION_TOKEN` and the returned resource IDs to your own values. See [session payments](/dev/guides/payments) for fees and [job handling](/dev/guides/jobs) before adding retries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.