> For the complete documentation index, see [llms.txt](https://docs.transactionlink.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.transactionlink.io/docs/v1/transactionlink-api/api-reference/token.md).

# Token

The `token` object represents a one-time token to the workflow for a specific Case.

Each token is unique to a client and has a duration of 60 minutes before it expires, providing a safe and time-limited way to utilize them in the frontend of your application.

{% hint style="info" %}
Remember to create a new case and a new token each time you initialize the widget for a new end user.
{% endhint %}

### `POST` Generate Token

## Generate widget token

> Differences between versions: version 1 relies on caseId and is scheduled for deprecation, whereas version 2 uses recordId (this field is optional) and is recommended moving forward.

```json
{"openapi":"3.0.3","info":{"title":"TransactionLink API","version":"1.0.0"},"tags":[{"name":"Token","description":"The token object represents a one-time token to the workflow for a specific case."}],"servers":[{"url":"https://api.transactionlink.io","description":"Production environment"}],"paths":{"/token":{"post":{"tags":["Token"],"summary":"Generate widget token","description":"Differences between versions: version 1 relies on caseId and is scheduled for deprecation, whereas version 2 uses recordId (this field is optional) and is recommended moving forward.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCaseWorkflowTokenDto"}},"application/json;version=2":{"schema":{"$ref":"#/components/schemas/CreateWorkflowTokenV2Dto"}}}},"responses":{"201":{"description":"Token has been generated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkflowTokenDto"}},"application/json;version=2":{"schema":{"$ref":"#/components/schemas/WorkflowTokenDtoV2"}}}},"400":{"description":"Request is invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Case or Record not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"CreateCaseWorkflowTokenDto":{"type":"object","required":["caseId","workflowDefinitionId"],"properties":{"caseId":{"type":"string","format":"uuid","description":"Case identifier for which we want to initiate the workflow"},"workflowDefinitionId":{"type":"string","description":"ID of the workflow definition"},"parametersId":{"type":"string","description":"ID of the parameters used in the workflow"}}},"CreateWorkflowTokenV2Dto":{"type":"object","required":["workflowDefinitionId"],"properties":{"recordId":{"type":"string","format":"uuid","description":"Record identifier for which we want to initiate the workflow"},"workflowDefinitionId":{"type":"string","format":"uuid","description":"ID of the workflow definition"},"parametersId":{"type":"string","format":"uuid","description":"ID of the parameters used in workflow"}}},"WorkflowTokenDto":{"type":"object","required":["token","expiryDuration","tokenType"],"properties":{"token":{"type":"string","description":"Widget token which should be set in widget"},"expiryDuration":{"type":"integer","description":"Token expiration in seconds"},"tokenType":{"type":"string","description":"Token type"}}},"WorkflowTokenDtoV2":{"type":"object","required":["id","token","expiryDuration","tokenType"],"properties":{"id":{"type":"string","description":"Token id"},"token":{"type":"string","description":"Widget token which should be set in widget"},"expiryDuration":{"type":"integer","description":"Token expiration in seconds"},"tokenType":{"type":"string","description":"Token type"}}},"ErrorResponse":{"type":"object","required":["fingerprint","errors"],"properties":{"fingerprint":{"type":"string","description":"error id"},"errors":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","description":"Error code"},"message":{"type":"string","description":"Error message"}}}}}}}}}
```
