# Create User Auth Token

<table data-header-hidden><thead><tr><th width="74.8046875" align="center"></th><th></th></tr></thead><tbody><tr><td align="center"><mark style="color:blue;"><strong>POST</strong></mark> </td><td>https://api.sfox.com/v1/enterprise/user-tokens/:user_id</td></tr></tbody></table>

Generate a user auth token for a specific end user.

***

User auth tokens are short-lived authentication tokens, expiring 24 hours after creation (expiration of a given token specified in the `expires` field of the response). User auth tokens are used for actions specific to a user's account (e.g. Initiate an ACH Deposit, Create an Order).&#x20;

{% hint style="info" %}
sFOX recommends that you do not store user auth tokens. Instead, create a new user auth token as needed whenever executing requests on behalf of a specific user.

There is no limit to the number of user auth tokens that may be created.

You can create user auth tokens for multiple users using [Create Multiple User Auth Tokens](/connect/rest-api/end-users/create-multiple-user-auth-tokens.md) requests.
{% endhint %}

## Request

### Path Parameters

<table><thead><tr><th width="199.6875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>user_id</code> <br><mark style="color:red;">required</mark>, string</td><td>ID of the specific user you want to create a user auth token for.</td></tr></tbody></table>

### Example Requests

{% tabs %}
{% tab title="Shell" %}

<pre class="language-shell" data-line-numbers><code class="lang-shell">export userId="156c5beb-7c9f-4f68-83c0-9479703ac490"

curl -X POST \
-H "Authorization: Bearer ${ENTERPRISE_API_KEY}" \
<strong>"https://api.sfox.com/v1/enterprise/user-tokens/${userId}"
</strong></code></pre>

{% endtab %}

{% tab title="NodeJS" %}
{% code lineNumbers="true" %}

```javascript
const axios = require('axios');

const userId = "156c5beb-7c9f-4f68-83c0-9479703ac490"

const config = {
  method: 'post',
  url: `https://api.sfox.com/v1/enterprise/user-tokens/${userId}`,
  headers: {
    "Content-Type": "application/json",
    'Authorization': `Bearer ${process.env.ENTERPRISE_API_KEY}`
  }
}

axios(config)
  .then(response => {
    console.log(response.status)
    console.log(response.data)
  }).catch(err => {
    console.error(err.response.status)
    console.error(err.response.data)
  });
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
import os

userId = "156c5beb-7c9f-4f68-83c0-9479703ac490"

data = requests.post(
  f"https://api.sfox.com/v1/enterprise/user-tokens/{userId}",
  headers={
    "Authorization": f"Bearer {os.environ['ENTERPRISE_API_KEY']}"
  }
)
print(data.status_code)
print(data.json())
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Response&#x20;

### Response Fields

<table><thead><tr><th width="199.9833606051543">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>data</code><br>object</td><td>User auth token information.</td></tr><tr><td>    <code>token</code><br>    string</td><td>The user authentication token that you will use to access this specific user's sFOX account</td></tr><tr><td>    <code>partner_user_id</code><br>    string</td><td>The <code>user_id</code> the token grants access to.</td></tr><tr><td>    <code>expires</code><br>    string</td><td>The expiration date of the user auth token. ISO-8601 date and time in UTC time zone.</td></tr></tbody></table>

### Responses

<details>

<summary><mark style="color:green;">201</mark> Created</summary>

{% code title="User auth token for a single user\_id" overflow="wrap" lineNumbers="true" %}

```json
{
    "data": {
        "token": "bcf5ab0aa8dfebc86460338514dd022d63080277373002e6986d7925375a0087",
        "partner_user_id": "client_db29326e-5df6-4d8b-aaaa-b75dc194a0a2",
        "expires": "2024-05-14T19:22:09.901Z"
    }
}
```

{% endcode %}

</details>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sfox.com/connect/rest-api/end-users/create-user-auth-token.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
