Skip to content

API authentication

Every request to the API runs on behalf of an invoiceR user. The application has exactly the permissions this user has through their roles.

invoiceR supports two ways of logging in to the API:

MethodHeaderValiditySuitable for
Access tokenAuthorization: Bearer <token>short, issued anew at every loginApplications that may know user name and password
Personal access token (PAT)Authorization: PAT <token>until the chosen expiry date, one year by defaultServices and scripts that should run without a password
  1. Send the user name (or e-mail address) and password to POST /api/TokenAuth/Authenticate:

    POST https://<server>/api/TokenAuth/Authenticate
    Content-Type: application/json
    { "userNameOrEmailAddress": "api-user", "password": "<password>" }
  2. The response contains the access token in the field result.accessToken.

  3. Send the token in the header of every further request:

    Authorization: Bearer <accessToken>

When the token expires, log in again.

A personal access token belongs to exactly one user. An application that uses it acts with the permissions of this user without knowing their password.

You create a PAT through the API, logged in as the user who should own the token:

  1. Log in as this user (for example as above with user name and password, or in the Swagger UI).

  2. Call POST /api/services/app/Authentication/CreatePersonalAccessToken and specify until when the token should be valid:

    POST https://<server>/api/services/app/Authentication/CreatePersonalAccessToken
    Authorization: Bearer <accessToken>
    Content-Type: application/json
    { "validUntil": "2027-10-31T00:00:00Z" }

    If you omit validUntil, the token is valid for one year. invoiceR rejects a date in the past.

  3. The response contains the token in plain text. Store it immediately in a safe place, for example in a password vault or in the configuration of the application.

Send the token with every request in the Authorization header with the prefix PAT:

GET https://<server>/api/services/app/Session/GetCurrentLoginInformations
Authorization: PAT <token>

invoiceR rejects the token if it has expired or if the user or the tenant is deactivated or deleted. Replace an expired token with a new one.