# Manage & Operate › Identity & Access Management › Identities › Personal Access Tokens API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Manage & Operate product's sections: https://developers.eu.ovhcloud.com/reference/manage-operate/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 5 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/identities/personal-access-tokens/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/manage-operate/identity-access-management/identities/personal-access-tokens.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/manage-operate/identity-access-management/identities/personal-access-tokens.json?format=openapi3

## Operations

- `GET /me/identity/user/{user}/token` — Retrieve all personal access tokens from this user
- `POST /me/identity/user/{user}/token` — Create a new personal access token
- `GET /me/identity/user/{user}/token/{name}` — Get a personal access token's information
- `PUT /me/identity/user/{user}/token/{name}` — Alter a user personal acces token
- `DELETE /me/identity/user/{user}/token/{name}` — Delete a personal access token

## Retrieve all personal access tokens from this user

`GET /1.0/me/identity/user/{user}/token`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/identities/personal-access-tokens/#get-me-identity-user-user-token

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/identity/user/token/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `user` | path | string | yes | User |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | string[] | successful operation |

```json
[
  "string"
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/identity/user/{user}/token" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/me/identity/user/{user}/token")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/me/identity/user/{user}/token");

print_r($result);
?>
```

## Create a new personal access token

`POST /1.0/me/identity/user/{user}/token`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/identities/personal-access-tokens/#post-me-identity-user-user-token

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/identity/user/token/create`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `user` | path | string | yes | User |

### Request body (required)

Type: `auth.PersonalAccessTokenRequest`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string | yes | Personal access token's description |
| `expiresAt` | string (date-time) |  | Personal access token's expiration date |
| `expiresIn` | integer |  | Duration (in seconds) of the token's validity |
| `name` | string | yes | Personal access token's name |

```json
{
  "description": "string",
  "expiresAt": "2024-01-01T12:00:00Z",
  "expiresIn": 0,
  "name": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | auth.PersonalAccessTokenResponse | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `creation` | string (date-time) | read-only | Creation date of this token |
| `description` | string | read-only | Personal access token's description |
| `expiresAt` | string (date-time) | read-only | Personal access token's expiration date |
| `lastUsed` | string (date-time) | read-only | Personal access token's last used date |
| `name` | string | read-only | Name of this token |
| `token` | string (password) | read-only | Personal access token |

```json
{
  "creation": "2024-01-01T12:00:00Z",
  "description": "string",
  "expiresAt": "2024-01-01T12:00:00Z",
  "lastUsed": "2024-01-01T12:00:00Z",
  "name": "string",
  "token": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/me/identity/user/{user}/token" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: auth.PersonalAccessTokenRequest
result = client.post("/me/identity/user/{user}/token",
	description = None, # Personal access token's description (type: string)
	expiresAt = None, # Personal access token's expiration date (type: string)
	expiresIn = None, # Duration (in seconds) of the token's validity (type: integer)
	name = None, # Personal access token's name (type: string)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: auth.PersonalAccessTokenRequest
$result = $ovh->post("/me/identity/user/{user}/token", array(
	description => null, // Personal access token's description (type: string)
	expiresAt => null, // Personal access token's expiration date (type: string)
	expiresIn => null, // Duration (in seconds) of the token's validity (type: integer)
	name => null, // Personal access token's name (type: string)
));

print_r($result);
?>
```

## Get a personal access token's information

`GET /1.0/me/identity/user/{user}/token/{name}`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/identities/personal-access-tokens/#get-me-identity-user-user-token-name

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/identity/user/token/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `name` | path | string | yes | Name |
| `user` | path | string | yes | User |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | auth.PersonalAccessToken | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `creation` | string (date-time) | read-only | Creation date of this token |
| `description` | string | read-only | Personal access token's description |
| `expiresAt` | string (date-time) | read-only | Personal access token's expiration date |
| `lastUsed` | string (date-time) | read-only | Personal access token's last used date |
| `name` | string | read-only | Name of this token |

```json
{
  "creation": "2024-01-01T12:00:00Z",
  "description": "string",
  "expiresAt": "2024-01-01T12:00:00Z",
  "lastUsed": "2024-01-01T12:00:00Z",
  "name": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/identity/user/{user}/token/{name}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/me/identity/user/{user}/token/{name}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/me/identity/user/{user}/token/{name}");

print_r($result);
?>
```

## Alter a user personal acces token

`PUT /1.0/me/identity/user/{user}/token/{name}`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/identities/personal-access-tokens/#put-me-identity-user-user-token-name

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/identity/user/token/edit`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `name` | path | string | yes | Name |
| `user` | path | string | yes | User |

### Request body (required)

Type: `auth.PersonalAccessTokenModifyRequest`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  | Personal access token's description |
| `expiresAt` | string (date-time) |  | Personal access token's expiration date |
| `expiresIn` | integer |  | Duration (in seconds) of the token's validity |

```json
{
  "description": "string",
  "expiresAt": "2024-01-01T12:00:00Z",
  "expiresIn": 0
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | auth.PersonalAccessToken | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `creation` | string (date-time) | read-only | Creation date of this token |
| `description` | string | read-only | Personal access token's description |
| `expiresAt` | string (date-time) | read-only | Personal access token's expiration date |
| `lastUsed` | string (date-time) | read-only | Personal access token's last used date |
| `name` | string | read-only | Name of this token |

```json
{
  "creation": "2024-01-01T12:00:00Z",
  "description": "string",
  "expiresAt": "2024-01-01T12:00:00Z",
  "lastUsed": "2024-01-01T12:00:00Z",
  "name": "string"
}
```

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/1.0/me/identity/user/{user}/token/{name}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: auth.PersonalAccessTokenModifyRequest
result = client.put("/me/identity/user/{user}/token/{name}",
	description = None, # Personal access token's description (type: string)
	expiresAt = None, # Personal access token's expiration date (type: string, nullable)
	expiresIn = None, # Duration (in seconds) of the token's validity (type: integer, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: auth.PersonalAccessTokenModifyRequest
$result = $ovh->put("/me/identity/user/{user}/token/{name}", array(
	description => null, // Personal access token's description (type: string)
	expiresAt => null, // Personal access token's expiration date (type: string, nullable)
	expiresIn => null, // Duration (in seconds) of the token's validity (type: integer, nullable)
));

print_r($result);
?>
```

## Delete a personal access token

`DELETE /1.0/me/identity/user/{user}/token/{name}`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/identities/personal-access-tokens/#delete-me-identity-user-user-token-name

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/identity/user/token/delete`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `name` | path | string | yes | Name |
| `user` | path | string | yes | User |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/me/identity/user/{user}/token/{name}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/me/identity/user/{user}/token/{name}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/me/identity/user/{user}/token/{name}");

print_r($result);
?>
```
