GET /api/users/:user_id/personal_access_tokens
List all Personal Access Tokens for a user

Examples

GET /api/users/988725680/personal_access_tokens
200
{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "created_at": "2021-09-01 10:46:48 UTC",
      "updated_at": "2021-09-01 10:46:48 UTC",
      "id": 4,
      "name": "Personal Access Token 5",
      "expires_at": "2021-09-11 10:46:48 UTC",
      "active?": true,
      "user_id": 988725680,
      "last_used_at": null,
      "revoked?": false
    }
  ]
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

user_id
required

ID of the user

Validations:

  • Must be a String

search
optional

filter results

Validations:

  • Must be a String

order
optional

Sort and order by a searchable field, e.g. ‘id DESC’

Validations:

  • Must be a String

page
optional

Page number, starting at 1

Validations:

  • Must be a number.

per_page
optional

Number of results per page to return, ‘all’ to return all results

Validations:

  • Must match regular expression /\A([1-9]\d|all)\Z$/.

Search fields

Field name Type Possible values
name string
user_id integer

GET /api/users/:user_id/personal_access_tokens/:id
Show a Personal Access Token for a user

Examples

GET /api/users/988725678/personal_access_tokens/1
200
{
  "created_at": "2021-09-01 10:46:47 UTC",
  "updated_at": "2021-09-01 10:46:47 UTC",
  "id": 1,
  "name": "Personal Access Token 3",
  "expires_at": "2021-09-11 10:46:47 UTC",
  "active?": true,
  "user_id": 988725678,
  "last_used_at": null,
  "revoked?": false
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

user_id
required

ID of the user

Validations:

  • Must be a String


POST /api/users/:user_id/personal_access_tokens
Create a Personal Access Token for a user

Examples

POST /api/users/988725679/personal_access_tokens
{
  "name": "foreman@example.com",
  "expires_at": "2021-09-29T10:46:48Z",
  "personal_access_token": {
    "name": "foreman@example.com",
    "expires_at": "2021-09-29T10:46:48Z"
  }
}
201
{
  "token_value": "u1Z89rauoromKQLM9wWBXw",
  "created_at": "2021-09-01 10:46:48 UTC",
  "updated_at": "2021-09-01 10:46:48 UTC",
  "id": 3,
  "name": "foreman@example.com",
  "expires_at": "2021-09-29 10:46:48 UTC",
  "active?": true,
  "user_id": 988725679,
  "last_used_at": null,
  "revoked?": false
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

user_id
required

ID of the user

Validations:

  • Must be a String

personal_access_token
required

Validations:

  • Must be a Hash

personal_access_token[name]
required

Validations:

  • Must be a String

personal_access_token[expires_at]
optional , nil allowed

Expiry Date

Validations:

  • Must be a DateTime


DELETE /api/users/:user_id/personal_access_tokens/:id
Revoke a Personal Access Token for a user

Examples

DELETE /api/users/988725682/personal_access_tokens/7
{
  "personal_access_token": {}
}
200
{
  "id": 7,
  "revoked": true,
  "token": "$2a$05$902ba3cda1883801594b6euDV9QJ6sqK6dZaU9/4tivo5WU/omuUC",
  "name": "Personal Access Token 7",
  "expires_at": "2021-09-11T10:46:49.018Z",
  "last_used_at": null,
  "user_id": 988725682,
  "created_at": "2021-09-01T10:46:49.019Z",
  "updated_at": "2021-09-01T10:46:49.049Z"
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String

user_id
required

ID of the user

Validations:

  • Must be a String