---
title: "Generate JWT Token"
method: POST
path: "/entity/{entityId}/token"
tags: ["entity"]
---

# Generate JWT Token

`POST /entity/{entityId}/token`

## Request

- Base URL: `https://api.mercoa.com`
- URL: `https://api.mercoa.com/entity/{entityId}/token`
- Auth: HTTP bearer

Generate a JWT token for an entity with the given options. This token can be used to authenticate the entity in the Mercoa API and iFrame.

<Warning>We recommend using [this endpoint](/api-reference/entity/user/get-token). This will enable features such as approvals and comments.</Warning>

## Path parameters

- `entityId` string, required

## Request body

- EntityTypesTokenGenerationOptions
  - `expiresIn` string: Expressed in seconds or a string describing a time span. The default is 1h.
  - `invoice` EntityTypesTokenGenerationInvoiceOptions
    - `lineItems` 'DISABLED' | 'OPTIONAL' | 'REQUIRED'
    - `status` InvoiceTypesInvoiceStatus[], required
    - `recurring` boolean: If true, recurring invoice templates will be available to the user.
  - `pages` EntityTypesTokenGenerationPagesOptions
    - `paymentMethods` boolean
    - `representatives` boolean
    - `notifications` boolean
    - `counterparties` boolean
    - `approvals` boolean
    - `emailLog` boolean
  - `style` EntityTypesTokenGenerationStyleOptions
    - `primaryColor` string, required
  - `vendors` EntityTypesTokenGenerationVendorOptions
    - `disableCreation` boolean: If true, the user will not be able to create new vendors.
    - `network` 'all' | 'platform' | 'entity', required
  - `entity` EntityTypesTokenGenerationEntityOptions
    - `enableMercoaPayments` boolean: If true, will require entity to undergo KYB to use Mercoa payment rails and will capture required KYB data in the portal.
  - `sessionId` string: Optional session ID to use for the token. If not provided, this token will not be associated with a session.

## Response `200`

Response with status 200

- string

## Other responses

- `400`: Error response with status 400
- `401`: Error response with status 401
- `403`: Error response with status 403
- `404`: Error response with status 404
- `409`: Error response with status 409
- `500`: Error response with status 500
- `501`: Error response with status 501

---

[API](https://skmtc.dev/mercoa/apis/mercoa-2.md) - [All operations](https://skmtc.dev/mercoa/apis/mercoa-2/llms.txt) - [OpenAPI document](https://skmtc.dev/mercoa/apis/mercoa-2/revisions/00a8e403ae18?raw)
