# Create Multiple User Auth Tokens

<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</td></tr></tbody></table>

Generate a user auth token for multiple end users.

***

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.

To create a user auth token for a single user, use a [Create Single User Auth Token](/connect/rest-api/end-users/create-user-auth-token.md) request.
{% endhint %}

## Request

### Body Parameters

<table><thead><tr><th width="245.44140625">Name</th><th>Description</th></tr></thead><tbody><tr><td><code>data</code> <br><mark style="color:red;">required</mark>, [string]</td><td>Array of <code>user_id</code> strings.</td></tr><tr><td>    <code>user_id</code> <br>    <mark style="color:red;">required</mark>, string</td><td>The IDs of the user(s) to create user auth tokens for. <em>At least 1</em> <code>user_id</code> <em>must be specified in the array.</em></td></tr></tbody></table>

### Example Requests

{% tabs %}
{% tab title="Shell" %}
{% code title="Create user auth tokens for 2 users with user\_id ${USER\_ID\_1} and ${USER\_ID\_2}" overflow="wrap" lineNumbers="true" %}

```shell
curl -X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ${ENTERPRISE_API_KEY}" \
--data '{ "data": ["${USER_ID_1}", "${USER_ID_2}"]}' \
'https://api.sfox.com/v1/enterprise/user-tokens'
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}
{% code title="Create user auth tokens for 2 users with user\_id ${USER\_ID\_1} and ${USER\_ID\_2}" lineNumbers="true" %}

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

const payload = JSON.stringify({
    "data": [
      '${USER_ID_1}',
      '${USER_ID_1}'
    ]
})

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

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 title="Create user auth tokens for 2 users with user\_id ${USER\_ID\_1} and ${USER\_ID\_2}" overflow="wrap" lineNumbers="true" %}

```python
import requests
import os

data = requests.post(
  "https://api.sfox.com/v1/enterprise/user-tokens",
  headers={
    "Authorization": f"Bearer {os.environ['ENTERPRISE_API_KEY']}",
  },
  json={
    "data": ["${USER_ID_1}", "${USER_ID_2}"]
  }
)
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>Array of user auth token objects.</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="Multiple users" lineNumbers="true" %}

```json
{
  "data": [
  {
    "token":"911b79b52d8921e57d55bfe4fa182e0e3982e1fa7f202ede548299b1118028f3",
    "expires": "2022-02-08T03:28:56Z",
    "partner_user_id": "156c5beb-7c9f-4f68-83c0-9479703ac490"
  },
  {
    "token":"811d79b52d8921e57d55bfe4fa182e0e3982e1fa7f202ede548299b1117467c5",
    "expires": "2022-02-08T03:28:56Z",
    "partner_user_id": "236f5cdc-7h82-6fh3-h37s-9382840de46575"
  }
  ]
}
```

{% 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-multiple-user-auth-tokens.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.
