---
title: "Generate JWT Token"
method: POST
path: "/entityGroup/{entityGroupId}/user/{foreignId}/token"
tags: ["entity-group > user"]
---

# Generate JWT Token

`POST /entityGroup/{entityGroupId}/user/{foreignId}/token`

## Request

- Base URL: `https://api.mercoa.com`
- URL: `https://api.mercoa.com/entityGroup/{entityGroupId}/user/{foreignId}/token`
- Auth: HTTP bearer

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

## Path parameters

- `entityGroupId` string, required
- `foreignId` 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)
