API secrets

Modified on Wed, 2 Dec at 2:56 PM

Use an API secret when another system needs to call the Omnidocs Create API, for example to generate documents. An API secret is a client ID and a client secret that belong to your organization. The system exchanges them for an access token and sends that token with each API call.

Before you begin

  • You need to be an organization administrator to manage API secrets.
  • Decide which units the calling system needs access to. You set the permissions when you create the secret, and they cannot be changed later.

Create an API secret

API secrets page

The API secrets page

  1. Open Settings and select API secrets under Organization.
  2. Click New API secret.
  3. Enter a Name that tells you which system uses the secret, for example "Case system production".
  4. Set the permissions. Select at least one, a secret without any permissions cannot be created:
    • Organization permissions: View, Edit or Manage for the whole organization.
    • Unit permissions: View, Edit or Manage per unit. To generate documents from a unit, the secret needs at least View on that unit. On units shared with your organization, only View is available.
  5. Leave Use basic authentication on all endpoints turned off unless the calling system cannot request a token. See Basic authentication on all endpoints.
  6. Click Create.

Creating an API secret

Creating an API secret

Create then shows the Client ID, the Client Secret and a ready-made Authorization header. Copy them and store them somewhere safe. The secret is only shown once. If you lose it, delete the API secret and create a new one.

The secret is only shown once

The client ID, client secret and authorization header are only shown once

Operator organizations also see Enable operator access on this API secret. Turn it on only if the secret is used for operator actions, such as creating and deleting sub-organizations.

Get an access token

Send the client ID and client secret to the token endpoint:

POST https://app.omnidocs.cloud/api/v1/oauth2/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=[Client ID]&client_secret=[Client Secret]

Instead of client_id and client_secret in the body, you can send the Authorization header shown when the secret was created, and only grant_type=client_credentials in the body.

Use the address that matches where your organization is hosted:

  • https://app.omnidocs.cloud if your organization's address ends in .omnidocs.cloud. This address is used in the examples in this article.
  • https://app.eu.omnidocs.cloud if your organization's address ends in .eu.omnidocs.cloud.
  • Your own address if Create is self-hosted.

The token endpoint is also described in the API reference: app.omnidocs.cloud/openapi, or app.eu.omnidocs.cloud/openapi for organizations on .eu.omnidocs.cloud.

The response looks like this (the values are examples):

{
  "access_token": "eyJhbGciOi...",
  "expires_in": 3600,
  "token_type": "Bearer"
}

expires_in is the number of seconds the token is valid. Request a new token when it expires.

Call the API

Send the token in the Authorization header of every request:

Authorization: Bearer [access_token]

For example, to generate a document:

POST https://app.omnidocs.cloud/api/v1/units/{unitId}/recipes/{recipeId}/generate
Authorization: Bearer [access_token]
Content-Type: application/json

{
  "data": { ... }
}

See Generate documents through the API for the request body.

Basic authentication on all endpoints

By default, the client ID and client secret can only be used on the token endpoint. If you turn on Use basic authentication on all endpoints when you create the secret, the calling system can send the Authorization header directly on every API call instead of requesting a token.

We recommend leaving this off. The client secret is then sent with every request, instead of a token that expires. This setting cannot be changed after the secret is created.

Rename or delete an API secret

On the API secrets page, open the menu next to a secret:

  • Rename changes the name only. The client ID, the secret and the permissions stay the same.
  • Delete removes the secret. The calling system can no longer request tokens, and tokens it already has stop working right away.

Double-click a secret to see its permissions. They cannot be edited. To change what a calling system can access, create a new API secret with the right permissions, update the calling system, and then delete the old secret.

Good to know

  • Create one API secret per calling system, so you can remove access for one system without affecting the others.
  • Give each secret only the permissions it needs. Most integrations that only generate documents need View on the units they generate from.
  • Treat the client secret like a password. Do not put it in code repositories, emails or tickets.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article