> For the complete documentation index, see [llms.txt](https://docs.codeocean.com/user-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codeocean.com/user-guide/code-ocean-api/authentication.md).

# Authentication

Code Ocean uses Access Tokens to authenticate requests. You can view and manage your access tokens from within your Dashboard under Access Tokens.

## To create an Access Token

1. Sign in to Code Ocean.
2. Click **Account.**
3. Click **Access Tokens.**
4. Click **Generate New Token.**
5. Provide the **Token Name.**&#x20;
6. **Select Scopes** allows you to select permissions for each resource.&#x20;
7. Click **Add Token.**
8. Click **Copy** to copy the Token, or click **Copy Token & Create Secret** to copy the token and store it as a secret in your Code Ocean account.
9. Click **Save Changes**.

<div align="center"><figure><img src="https://content.gitbook.com/content/IXW7wvn1GtkljhxGS08z/blobs/6gx7VinQlDI1c3rFwwm0/create%20access%20token.gif" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
The access token only shows when it is created, so be sure to copy it or click **Copy Token & Create Secret** to copy the token and store it as a secret in your Code Ocean account.

**You will not be able to access it again.**&#x20;

By adding the access token as a secret in your Code Ocean account, it will be easily accessible in a Capsule. See the [Accessing a Secret in a Capsule](/user-guide/compute-capsule-basics/secret-management-guide/attaching-a-secret-to-a-capsule.md) page for more information.
{% endhint %}

## To view an Access Token

1. Navigate to **Account.**
2. Click **Access Tokens** and a list of Access Tokens will be shown.

## To delete an Access Token

1. Next to the Token, click the garbage can <img src="https://content.gitbook.com/content/IXW7wvn1GtkljhxGS08z/blobs/dxgUmUR7yiZSW2TJE450/Delete.gif" alt="" data-size="line">.<br>

   <div align="center"><figure><img src="https://content.gitbook.com/content/IXW7wvn1GtkljhxGS08z/blobs/NC2XfasiMMKSOZx3pI2c/Delete%20API.gif" alt="" width="375"><figcaption></figcaption></figure></div>
2. Click **Delete**.

## Using an access token in API requests

### cURL

The API uses [HTTP Basic Authentication](http://en.wikipedia.org/wiki/Basic_access_authentication). Pass your access token as the username with an empty password.

<pre class="language-bash"><code class="lang-bash"><strong>curl https://{domain}/api/v1/capsules/4bc97533-6eb4-48ac-966f-648548a756d2 \
</strong>  -u "cop_xxxxxxxxxx:"
</code></pre>

The resulting Authorization header:

```
Authorization: Basic {encoded-token}
```

### Python SDK

Use your access token when creating a `CodeOcean` client. The Python library will then automatically send this key in each request.

<pre class="language-bash"><code class="lang-bash"><strong>$ pip install codeocean
</strong></code></pre>

```python
from codeocean import CodeOcean

client = CodeOcean(domain="https://{domain}", token="cop_xxxxxxxxxx")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.codeocean.com/user-guide/code-ocean-api/authentication.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
