> ## Documentation Index
> Fetch the complete documentation index at: https://docs.commenda.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create credential

> Create a new credential for storing portal login information

Create a credential to store login details for a government tax portal. Use the [Portal Fields](/engine/indirect-tax/registrations/v2/content/portal-fields-POST) endpoint to discover what fields a portal requires.

## Request body

<ParamField body="corporation_id" type="string" required>
  The unique identifier (UUID) for the corporation.
</ParamField>

<ParamField body="credential_type" type="string" required>
  The type of credential. Values: `INDIRECT_TAX_REGISTRATION`, `OTHER`.
</ParamField>

<ParamField body="blocks" type="array" required>
  Array of credential blocks. Each block stores one field (e.g., username, password). Minimum 1 block required.

  Each block requires:

  * `block_key` — unique key for the field (e.g., `username`)
  * `block_label` — display label (e.g., `Username`)
  * `block_type` — one of `String`, `SecureString`, `File`
  * `value` — the field value
</ParamField>

<ParamField body="portal_id" type="string">
  The portal ID to associate the credential with. Get this from the [Portal Fields](/engine/indirect-tax/registrations/v2/content/portal-fields-POST) endpoint.
</ParamField>

<ParamField body="name" type="string">
  A display name for the credential.
</ParamField>

<ParamField body="portal_url" type="string">
  URL of the tax portal.
</ParamField>

<ParamField body="notes" type="string">
  Optional notes about the credential.
</ParamField>

<ParamField body="is_custom" type="boolean">
  Whether this is a custom (user-defined) credential rather than a portal-driven one.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://transaction-tax.api.in.commenda.io/api/v1/credentials' \
    --header 'Authorization: Bearer <your_token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "corporation_id": "550e8400-e29b-41d4-a716-446655440000",
      "credential_type": "INDIRECT_TAX_REGISTRATION",
      "portal_id": "PORTAL_CA_CDTFA",
      "name": "California CDTFA Portal",
      "blocks": [
        {
          "block_key": "username",
          "block_label": "Username",
          "block_type": "String",
          "value": "user@example.com"
        },
        {
          "block_key": "password",
          "block_label": "Password",
          "block_type": "SecureString",
          "value": "my-secure-password"
        }
      ]
    }'
  ```

  ```json Standard theme={null}
  {
    "corporation_id": "550e8400-e29b-41d4-a716-446655440000",
    "credential_type": "INDIRECT_TAX_REGISTRATION",
    "portal_id": "PORTAL_CA_CDTFA",
    "name": "California CDTFA Portal",
    "blocks": [
      {
        "block_key": "username",
        "block_label": "Username",
        "block_type": "String",
        "value": "user@example.com"
      },
      {
        "block_key": "password",
        "block_label": "Password",
        "block_type": "SecureString",
        "value": "my-secure-password"
      }
    ]
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "message": "Successfully created credential.",
    "data": {
      "credential": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
      }
    }
  }
  ```

  ```json 400 - Invalid credential type theme={null}
  {
    "message": "Validation failed.",
    "error": {
      "type": "CLIENT_INVALID_REQUEST_BODY",
      "title": "Failed to validate the request body",
      "detail": {
        "description": "invalid credential_type: INVALID"
      },
      "status": 400,
      "instance": "/api/v1/credentials"
    }
  }
  ```

  ```json 400 - Invalid block type theme={null}
  {
    "message": "Validation failed.",
    "error": {
      "type": "CLIENT_INVALID_REQUEST_BODY",
      "title": "Failed to validate the request body",
      "detail": {
        "description": "blocks[0]: invalid block_type: INVALID"
      },
      "status": 400,
      "instance": "/api/v1/credentials"
    }
  }
  ```
</ResponseExample>
