> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trelent.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get an access token

> Exchange client credentials for an OAuth2 access token.

The body is form-encoded. `grant_type` must be `client_credentials`.

Ask for every scope that you need, as one string with a space between each
scope. The authorization server grants only the scopes that you ask for,
and only the scopes that your client holds. The `scope` field of the answer
gives what you received.

Send the token in the `Authorization` header as `Bearer <token>`.



## OpenAPI

````yaml document-verification/api-reference/openapi.json POST /token
openapi: 3.1.0
info:
  title: Trelent Document Verification API
  description: >

    Trelent Document Verification integrates with your platform to assess fraud

    risk in financial and identity documents. The API returns a fraud score

    and detailed reasoning. Your team builds the integration to display these

    results in your interface and support human review. Trelent can help you
    build

    that integration.


    Use cases include loan application review and legal document review.


    Your end-users submit documents through your platform.


    Document Verification is always deployed in your cloud environment. Your
    data

    is never sent to or retained on Trelent servers.


    ## How a detection runs


    Detection is asynchronous. `POST /v1/detection` answers `202` immediately
    with

    a detection id and the status `QUEUED`. A workflow then prepares the
    document,

    runs the deterministic checks, and runs the analysis agent. Read the result

    with `GET /v1/detection/{detection_id}` until the status is `COMPLETED` or

    `FAILED`.


    ## How you supply a document


    Each create request names its documents in one of two ways, and exactly one
    of

    the two must be present:


    - `source_url` — the API downloads the document
      from a URL that you supply. Use this method for API integrations.
    - `upload_id` — the caller has already written the files to object storage.
      API integrations should use `source_url`.

    ## Authentication


    Every `/v1` operation needs an OAuth2 access token from the

    `client_credentials` grant. Put the token in the `Authorization` header as

    `Bearer <token>`.


    In most cases the scope `DocumentVerification:*` covers every operation, so

    request that if your client holds it. The description of each operation also

    names the narrower scope it needs.
  version: 1.0.0
servers: []
security: []
tags:
  - name: Detections
    description: >-
      Verify one document. A detection starts as `QUEUED` and gives no verdict
      until the status becomes `COMPLETED`.
  - name: Authentication
    description: Exchange client credentials for an access token.
paths:
  /token:
    post:
      tags:
        - Authentication
      summary: Get an access token
      description: >-
        Exchange client credentials for an OAuth2 access token.


        The body is form-encoded. `grant_type` must be `client_credentials`.


        Ask for every scope that you need, as one string with a space between
        each

        scope. The authorization server grants only the scopes that you ask for,

        and only the scopes that your client holds. The `scope` field of the
        answer

        gives what you received.


        Send the token in the `Authorization` header as `Bearer <token>`.
      operationId: get_token_token_post
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Body_get_token_token_post'
        required: true
      responses:
        '200':
          description: An access token and the scopes that the token holds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          description: The grant type is not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: The client credentials are not valid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '503':
          description: The token endpoint is not configured.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Body_get_token_token_post:
      properties:
        grant_type:
          type: string
          title: Grant Type
        client_id:
          type: string
          title: Client Id
        client_secret:
          type: string
          title: Client Secret
        scope:
          type: string
          title: Scope
          default: ''
      type: object
      required:
        - grant_type
        - client_id
        - client_secret
      title: Body_get_token_token_post
    TokenResponse:
      properties:
        access_token:
          type: string
          title: Access Token
        token_type:
          type: string
          title: Token Type
          default: bearer
        expires_in:
          type: integer
          title: Expires In
        scope:
          type: string
          title: Scope
      type: object
      required:
        - access_token
        - expires_in
        - scope
      title: TokenResponse
      description: An OAuth2 access token and the scopes the token holds.
    ErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: ErrorResponse
      description: Every error answer holds one message in `detail`.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````