---
updatedAt: 2026-04-21T08:57:19.000Z
agentTools:
  projectIndex: https://docs.mesh.complyadvantage.com/llms.txt
---

# Create an access token with username/password (legacy)

**This endpoint remains fully supported. For new implementations, we strongly recommend using [API access tokens](https://docs.mesh.complyadvantage.com/v0.3/reference/createtokenv3) going forward.**

Mesh is authenticated via OAuth2.  An initial request must be made to collect the token. This token can then be used to authenticate all requests for the following 24 hours, after which the token must be refreshed.

The username and password should be one of the users already created in your account. The value `realm` is provided by ComplyAdvantage.

The access token returned by the initial request can then be used within the authorization header.

```
"Authorization":"Bearer {access_token}"
```

The bearer token has a validity period of 24 hours (86,400 seconds), after which any authentication attempts will fail.  To refresh a token, use the same method as that used to generate it.

# OpenAPI definition

````json
{
  "components": {
    "schemas": {
      "TokenCreateRequestBody": {
        "properties": {
          "password": {
            "description": "The password of the API user",
            "example": "password",
            "type": "string"
          },
          "realm": {
            "description": "This will have been provided by ComplyAdvantage at onboarding.  Note this is case sensitive.",
            "example": "yourrealm",
            "type": "string"
          },
          "username": {
            "description": "The username (email address) of the API user",
            "example": "yourapiuser@yourdomain.com",
            "format": "email",
            "type": "string"
          }
        },
        "required": [
          "username",
          "password",
          "realm"
        ],
        "type": "object"
      },
      "TokenCreateResponseData": {
        "properties": {
          "access_token": {
            "description": "The generated token that should be included in the authorization header of each call (`Authorization: Bearer {access_token}`)",
            "example": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "type": "string"
          },
          "expires_in": {
            "description": "The number of seconds until the token expires",
            "example": 86400,
            "type": "integer"
          },
          "scope": {
            "enum": [
              "read:api write:api"
            ],
            "type": "string"
          },
          "token_type": {
            "enum": [
              "Bearer"
            ],
            "type": "string"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "description": "HTTP Bearer Token Authentication",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "title": "Mesh API",
    "version": "v2.0"
  },
  "openapi": "3.0.3",
  "paths": {
    "/v2/token": {
      "post": {
        "description": "**This endpoint remains fully supported. For new implementations, we strongly recommend using [API access tokens](https://docs.mesh.complyadvantage.com/v0.3/reference/createtokenv3) going forward.**\n\nMesh is authenticated via OAuth2.  An initial request must be made to collect the token. This token can then be used to authenticate all requests for the following 24 hours, after which the token must be refreshed.\n\nThe username and password should be one of the users already created in your account. The value `realm` is provided by ComplyAdvantage.\n\nThe access token returned by the initial request can then be used within the authorization header.\n\n```\n\"Authorization\":\"Bearer {access_token}\"\n```\n\nThe bearer token has a validity period of 24 hours (86,400 seconds), after which any authentication attempts will fail.  To refresh a token, use the same method as that used to generate it.",
        "operationId": "createToken",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenCreateRequestBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/TokenCreateResponseData"
                }
              }
            },
            "description": "OK"
          },
          "400": {
            "content": {
              "*/*": {
                "schema": {
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_description": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Bad Request"
          }
        },
        "security": [
          {}
        ],
        "summary": "Create an access token with username/password (legacy)",
        "tags": [
          "Authentication"
        ]
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "servers": [
    {
      "description": "ComplyAdvantage Mesh API",
      "url": "https://api.mesh.complyadvantage.com"
    }
  ],
  "tags": [
    {
      "name": "Authentication"
    }
  ]
}
````