> This page is for version v2.
> For other versions, use one of these documentation indexes:
> - v1 (default): https://doc.youratlas.com/v1/llms.txt
> - v2: https://doc.youratlas.com/v2/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://doc.youratlas.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://doc.youratlas.com/_mcp/server.

# OAuth credentials

Many APIs want an OAuth token, not a fixed key. Atlas Actions support the **Client Credentials** grant. You save the connection once. After that, Atlas gets a token before each action calls your API. Nobody pastes a new token.

You can save more than one connection and choose one per action.

## When to use OAuth

* Your API uses OAuth 2 Client Credentials, where one system signs in as another.
* You don't want a long-lived key sitting in a header.
* You want one sign-in shared by several actions.

For a fixed API key or bearer token, add a header to the action instead. See [HTTP Headers](/v2/integrations/atlas-actions/create-a-custom-action#http-headers).

## Add a connection

You add connections from inside an action form. That is any custom action, including **Create from scratch**.

1. In **Authentication**, select **Create New**.
2. Fill in the form:
   * **Connection Name.** A label such as `Production CRM`. It shows in the list later.
   * **Client ID.** From your OAuth app.
   * **Client Secret.** From your OAuth app. The field hides what you type.
   * **Authentication Method.** The only choice is **Basic Authentication**. Atlas sends the client ID and secret to the token endpoint in a `Basic` header.
   * **Token Endpoint.** The full address where your provider issues tokens, for example `https://auth.example.com/oauth/token`. It must be a valid URL.
   * **Scopes.** Optional. Type a scope to add it. Add as many as you need.
   * **Audience.** Optional, for providers that need one, such as Auth0.
3. Select **Create**.

Connection Name, Client ID, Client Secret and Token Endpoint are required. The form says which is missing: "Connection name is required", "Client ID is required", "Client secret is required", "Token endpoint URL is required". A bad address gives "Token endpoint must be a valid URL".

Atlas tests the credentials against your token endpoint first. If the test fails, nothing is saved and the form shows the reason, such as `Token request failed: Invalid client credentials`. Fix the field and try again.

When the connection is saved, it's selected on the action you were editing.

If you save a connection with a name you already used, it replaces the earlier one. Use a new name to keep both.

Audience goes to your token endpoint during that test. Atlas doesn't keep it with the saved connection. Later token requests go out without it. If your provider needs an audience on every token, use an HTTP header with a token you manage instead.

You can't edit or delete a saved connection in the portal today. To change one, save it again with the same name.

## Use a saved connection

In an action form, open **OAuth Client Credential Connection** under **Authentication** and pick one. Pick **None** to turn authentication off.

Each time the action runs, Atlas:

1. Asks your token endpoint for a token. It reuses a token it already has until about a minute before it expires. If your provider doesn't say how long a token lasts, Atlas assumes an hour.
2. Adds the header `Authorization: Bearer <token>` to the request.

You don't add an `Authorization` header yourself.

If Atlas can't get a token, the action fails and your API isn't called. The agent says its failure message.

## What Atlas sends to the token endpoint

A standard client credentials request. The client ID and secret go in the `Basic` header. The body has `grant_type=client_credentials`. It adds `scope`, your scopes separated by spaces, when you set them.

## Where connections live

Connections belong to your account, not to one action. Every action form shows the same list, so one connection serves many actions.

## Troubleshooting

When saving, the form can show one of these:

| Message                                                                     | What to check                                           |
| --------------------------------------------------------------------------- | ------------------------------------------------------- |
| `Token request failed: Invalid client credentials` or `Invalid credentials` | The Client ID and Client Secret.                        |
| `Token request failed: Invalid scope`                                       | The scopes your provider allows.                        |
| `Token request failed: Invalid grant` or `Unauthorized client`              | Your OAuth app must allow the Client Credentials grant. |
| `Token request failed: Token endpoint not found`                            | The Token Endpoint address.                             |
| `Token request failed: Access forbidden`                                    | The app's permissions at your provider.                 |
| `Token request failed: Server error - try again later`                      | Your provider. Try again soon.                          |

When an action runs:

* `Authentication failed: ...` means Atlas couldn't get a token. The connection may have been replaced, or the provider may be down. Open the action and pick the connection again.
* A `401` from your API means it refused the token. Check that the credentials are still valid and the scopes cover this endpoint.
* A `403` means the token is valid but not allowed on this endpoint. Add the scopes it needs.

## Related

* [Create a custom action](/v2/integrations/atlas-actions/create-a-custom-action#authentication)
* [Atlas Actions overview](/v2/integrations/atlas-actions)