Skip to content

Create

Generate new bearer authentication token.

Endpoint

http
POST /api/v1/user/tokens

Parameters

Body parameters

ParameterTypeRequiredDescription
namestringyesThe name of the token.

Request example

sh
curl --location --request POST 'https://files.ro/api/v1/user/tokens' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {token}' \
--data-raw '{
  "name": "My Custom App"
}'

Response

json
{
  "accessToken": {
    "id": 1,
    "tokenable_type": "App\\Users\\Models\\User",
    "tokenable_id": "user_123",
    "name": "CLI",
    "abilities": [
      "*"
    ],
    "last_used_at": "2024-01-01T00:00:00.000000Z",
    "expires_at": null,
    "created_at": "2024-01-01T00:00:00.000000Z",
    "updated_at": "2024-01-01T00:00:00.000000Z"
  },
  "plainTextToken": "1|plain_text_token"
}
json
{
  "type": "error",
  "message": "You are not authorized"
}
json
{
  "message": "The given data was invalid.",
  "errors": {
    "field": [
      "The field is required."
    ]
  }
}