---
updatedAt: 2026-03-01T18:53:52.000Z
agentTools:
  siteIndex: https://techdocs.akamai.com/llms.txt
  projectIndex: https://techdocs.akamai.com/mfa/llms.txt
---

# Assign a hardware token

```curl cURL
userId="user_2eVKpVVpgzM3fPWsao3sbh"

egcurl --eg-section default --request POST \
  --url "https://$hostname/amfa/v1/users/$userId/devices/assign-hardware-token" \
  --header "Accept: application/json" \
  --header "Content-Type: application/json" \
  --data '
{
    "deviceId": "device_5Vv4g1iex1ntW5L1bQbcaG"
}'
```

```node Node
const EdgeGrid = require("akamai-edgegrid");
const os = require("os");
const edgercPath = os.homedir + "/.edgerc.txt";
const edgercSection = "default";
const eg = new EdgeGrid({
  path: edgercPath,
  section: edgercSection,
});

const userId = "user_2eVKpVVpgzM3fPWsao3sbh";

eg.auth({
  path: `/amfa/v1/users/${userId}/devices/assign-hardware-token`,
  method: "POST",
  headers: {
    "Content-Type": "application/json",

    Accept: "application/json",
  },
  body: {
    deviceId: "device_5Vv4g1iex1ntW5L1bQbcaG",
  },
});
eg.send(function (error, response, body) {
  console.log(JSON.stringify(JSON.parse(body), null, 2));
});
```

```python Python
import requests
import json
from akamai.edgegrid import EdgeGridAuth, EdgeRc
from urllib.parse import urljoin

edgerc = EdgeRc('~/.edgerc.txt')
section = 'default'
baseurl = 'https://%s' % edgerc.get(section, 'host')

session = requests.Session()
session.auth = EdgeGridAuth.from_edgerc(edgerc, section)
userId = "user_2eVKpVVpgzM3fPWsao3sbh"
 

path = '/amfa/v1/users/{}/devices/assign-hardware-token'.format(userId)
headers = {
  "Content-Type": "application/json",

  "Accept": "application/json"}
payload = {
    "deviceId": "device_5Vv4g1iex1ntW5L1bQbcaG"
}  

result = session.post(urljoin(baseurl, path), headers=headers, json=payload)
print(result.status_code)
print(json.dumps(result.json(), indent=2)) 
```

```json Response Example
{"success":true}
```

# Set up authentication

<!-- curl@3 -->
<!-- node@1-8 -->
<!-- python@1-11 -->

Before you can use this API, you need to [Create authentication credentials](https://techdocs.akamai.com/developer/docs/set-up-authentication-credentials).

Then, you can include this code to apply the token values to validate your requests.

Refer to [EdgeGrid libraries](https://techdocs.akamai.com/developer/docs/authenticate-with-edgegrid#edgegrid-libraries) to install the necessary modules for various programming languages.

# Set your path parameters

<!-- curl@1 -->
<!-- node@10 -->
<!-- python@12 -->

Include the following path value:
- `userId`. A unique identifier for the user account. If you need this value, run [List users](https://techdocs.akamai.com/mfa/reference/get-users).

# Form the request URL

<!-- curl@4 -->
<!-- node@13 -->
<!-- python@15 -->

Specify the target endpoint.

# Build the body request object

<!-- curl@7-10 -->
<!-- node@20-22 -->
<!-- python@20-22 -->

Add the following body parameter:
- `deviceId`. A unique identifier for the hardware token. You can assign only one token to a specific user account.

# Call the API

<!-- curl@1-10 -->
<!-- node@1-26 -->
<!-- python@1-26 -->

Call POST on the request URL, providing the body request object.

# View the response



A 202 response indicates successful assignment.