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

# Token for a Contact

It is possible for financial institutions to get an access token on behalf of their clients by using the contact id of the client.

This functionality is not available per default, you need to contact Ebury to enable it for each contact you need an access token for.

This endpoint is only available using mTLS.


## OpenAPI

````yaml /openapi/ebury-spec.json post /token/{contact_id}
openapi: 3.0.0
info:
  description: |
    Ebury API allows customers:
      to retrieve accounts, balances, beneficiaries, and transactions;
      to get buy/sell estimates and quotes, book trades and retrieve trade history;
      to allocate payments to a trade and beneficiary, and to submit payments in bulk;
      to download documents such as trade receipt, payment instruction and payment receipt;
      to manage the authorised persons on their account.
    The Metadata API allows applications to clarify some parts of the Ebury API
      that are impractical to express schematically.
  termsOfService: https://docs.ebury.io/#terms-of-use
  title: Ebury API
  version: '0.1'
servers:
  - url: https://{environment}.ebury.io
    variables:
      environment:
        default: api
        enum:
          - api
          - sandbox
security:
  - api_key: []
paths:
  /token/{contact_id}:
    post:
      tags:
        - TrustedAuthentication
      summary: Token for a Contact
      description: >-
        Get an access token or refresh an existing one. The access token is
        passed in the Authorization header parameter in endpoints that require
        authentication.
      parameters:
        - name: Authorization
          in: header
          description: >-
            Where credentials is a Base64 encoded string of
            auth_client_id:auth_client_secret
          required: true
          schema:
            type: string
        - name: contact_id
          in: path
          description: The id of the contact
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Listf of contacts IDs that are from the given client
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostTokenForContactResponse'
        '400':
          description: >-
            Formatting or schema validation error or invalid data.See error
            message for further details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorMessage'
        '401':
          description: Unauthorized. See error message for further details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorMessage'
        '429':
          description: Too many requests
          content: {}
        '495':
          description: Certificate Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorMessage'
        '496':
          description: No Cert. There was not certificate provided.
          content: {}
        '497':
          description: HTTP to HTTPS. The connection was made using HTTP instead of HTTPS.
          content: {}
components:
  schemas:
    PostTokenForContactResponse:
      type: object
      properties:
        access_token:
          type: string
          description: An OAuth access token that can be used to call the API
        token_type:
          type: string
          description: >-
            The Authorization header scheme to use when making requests, will be
            Bearer.
          enum:
            - Bearer
        expires_in:
          type: string
          description: >-
            Expiry period in seconds from time token returned, currently returns
            3600 (1 hour).
        id_token:
          type: string
          description: >-
            A signed, base 64 encoded JSON Web Token that provides verification
            of the identity that authorized the request. The token includes the
            client identifier, which is a required parameter on the majority of
            API calls.
      description: Access token data
    AuthErrorMessage:
      type: object
      properties:
        error:
          type: string
          description: The code for the error.
        error_description:
          type: string
          description: A short description of the cause of the error.
      description: An error message.
  securitySchemes:
    api_key:
      description: An API Key.
      in: header
      name: x-api-key
      type: apiKey

````