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

# Use the platform API from the CLI

> Discover platform operations and compose them with your saved ContextLayer login.

`ctx api` lets you discover platform operations, inspect their contracts, and use one operation's result in another. Newly published operations appear without waiting for a CLI release.

Follow [Installation](https://docs.usecontextlayer.com/installation.md) to sign in before making authenticated calls.

## Discover an operation

List the live operations, then inspect the slate-listing operation:

```sh theme={null}
npx @usecontextlayer/cli api --help
npx @usecontextlayer/cli api listSlates --help
npx @usecontextlayer/cli api listSlates --describe
```

The [API reference](https://docs.usecontextlayer.com/api-reference/slates/list-slates-the-caller-can-manage.md) uses the same contract. Read it before invoking an unfamiliar operation to understand its inputs, authorization, and result. Use the command's help for CLI input and output rules.

## Make a request and use its result

List the slates your account manages:

```sh theme={null}
npx @usecontextlayer/cli api listSlates
```

Choose a slate from `data.slates`, then use its ID to read its details:

```sh theme={null}
npx @usecontextlayer/cli api getSlate --describe
npx @usecontextlayer/cli api getSlate --params '{"target":"<slate-id>"}'
```

Interpret `data` using the operation's contract. See [Build an agent](https://docs.usecontextlayer.com/how-to/build-an-agent.md#start-a-hosted-job-and-inspect-it) for a workflow that sends a request body, waits for a result, and reads execution messages.

## Call HTTP from another program

For a program that makes HTTP requests directly, obtain a current access token through the CLI:

```sh theme={null}
access_token=$(npx @usecontextlayer/cli token)
curl --header "Authorization: Bearer $access_token" \
  https://platform.usecontextlayer.com/api/slates
```

Obtain the token when your program needs it so the CLI selects the login and refreshes it if necessary, rather than reading the saved credential file.


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