---
title: Create a Consent
slug: connect/create-a-consent
docTags: 
createdAt: 2023-11-21T06:38:02.824Z
---

:::ApiMethodV2
```json
{
  "name": "consents",
  "method": "POST",
  "url": "https://api-sandbox.klavi.ai/data/v1/consents",
  "description": "Create a consent by linkToken",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "2XGmRR1EXJF8_8SRjSvPr",
        "language": "curl",
        "code": "curl --location 'https://api-sandbox.klavi.ai/data/v1/consents' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\"externalTrackId\":\"string\",\"personalTaxId\":\"string\",\"businessTaxId\":\"string\",\"institutionCode\":\"string\",\"redirectURL\":\"string\",\"phone\":\"string\",\"email\":\"string\",\"validityPeriod\":12}'",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "2XGmRR1EXJF8_8SRjSvPr"
  },
  "results": {
    "languages": [
      {
        "id": "seNGgBV6qGeHWBvI_ZAl6",
        "language": "200",
        "customLabel": "",
        "code": "{\n    \"consentId\": \"0325412e-e566-4f4e-ac5b-2f4471586b88\",\n    \"consentRedirectURL\": \"https://auth.mockbank.poc.raidiam.io/auth?client_id=_uWJuSDGCWFQuNoKrJP0o&scope=openid%20consent%3Aurn%3Araidiambank%3A76bfad6b\",\n    \"expireAt\": \"2024-11-21T23:59:59Z\"\n}"
      }
    ],
    "selectedLanguageId": "seNGgBV6qGeHWBvI_ZAl6"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [
      {
        "name": "Authorization",
        "kind": "required",
        "type": "string",
        "description": "Bearer link token, it returned by the /links",
        "children": []
      }
    ],
    "bodyDataParameters": [
      {
        "name": "externalTrackId",
        "kind": "required",
        "type": "string",
        "description": "Partners to transfer tracking information, each value must be unique"
      },
      {
        "name": "personalTaxId",
        "kind": "required",
        "type": "string",
        "description": "The CPF of the end-user, for Personal Accounts only(If end user is personal required)",
        "children": []
      },
      {
        "name": "businessTaxId",
        "kind": "optional",
        "type": "string",
        "description": "The CNPJ of the company, for Business Accounts only(If end user is business required)",
        "children": []
      },
      {
        "name": "institutionCode",
        "kind": "required",
        "type": "string",
        "description": "Institution code, it returned by the /institutions",
        "children": []
      },
      {
        "name": "redirectURL",
        "kind": "required",
        "type": "string",
        "description": "The URL for redirection upon successful link initialization",
        "children": []
      },
      {
        "name": "phone",
        "kind": "optional",
        "type": "string",
        "description": "End user's phone, compliance needs",
        "children": []
      },
      {
        "name": "email",
        "kind": "optional",
        "type": "string",
        "description": "End user's email, compliance needs",
        "children": []
      },
      {
        "name": "clientMetadata",
        "kind": "optional",
        "type": "Object",
        "description": "Client metadata, recommended",
        "children": [
          {
            "name": "platform",
            "kind": "required",
            "type": "String",
            "description": "Client type, Enum: [ BROWSER, APP ]"
          },
          {
            "name": "os",
            "kind": "required",
            "type": "string",
            "description": "OS type, Enum: [ LINUX, MACOS, UNIX, WINDOWS, IOS, ANDROID, OTHER ]"
          },
          {
            "name": "osVersion",
            "kind": "optional",
            "type": "string",
            "description": "OS version, Defaults to N/A"
          }
        ]
      },
      {
        "name": "validityPeriod",
        "kind": "required",
        "type": "number",
        "description": "The expiration month of the consent. \nIf validityPeriod equals 0, the consent will have indefinite validity;\nIf validityPeriod equals 12, the consent form will only have a validity period of 12 months.\nEnum: [0, 12]",
        "": "The expiration month of the consent. \nIf validityPeriod equals 0, the consent will have indefinite validity;\nIf validityPeriod equals 12, the consent form will only have a validity period of 12 months.\nEnum: [0, 12]"
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "response": [
    {
      "name": "consentId",
      "kind": "optional",
      "type": "string",
      "description": "Consent identify\nmaxLength: 36"
    },
    {
      "name": "consentRedirectURL",
      "kind": "optional",
      "type": "string",
      "description": "Consent redirect URL, when the front-end of the partner requests this URL, the browser will redirect to the corresponding participant's authorization page, which will pop up the current Link web page.\nThis url can only be accessed once, and it has 60 seconds to be accessed. \nIf the user revokes their consent, or if their validity period has reached 60 minutes, the status will be transferred to REJECTED. Accessing this URL will also return a failure.",
      "children": []
    },
    {
      "name": "expireAt",
      "kind": "optional",
      "type": "string",
      "description": "Consent(Specifically referring to the consensId) expire time(UTC timezone)",
      "children": []
    }
  ],
  "autoGeneratedAnchorSlug": "consents",
  "legacyHash": "cPPKEi5QBnWmZ6kL8UL8B"
}
```
:::

## Parameter

### redirectURL

The end-user completes authorization and returns to the client's page URL from the LGDP page.

- &#x20;If authorization succeeds, the Klavi backend returns the `redirectURL` with the `link_id` , `consent_id`,`external_info` and `external_track_id` parameters
- If authorization fails, the Klavi backend returns the `redirectURL` with the `link_id`, `consent_id`, `external_info` , `external_track_id` ,`error` and `error_description` parameters

