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

# Generate Signature

Use this API to generate a secure signature for Permission Provider responses. The signature validates the integrity of permission decisions returned from your authorization service.

<Warning>
  **Security Critical:** This endpoint must be called from your backend server, never from client-side code. The signature ensures that permission responses haven't been tampered with.
</Warning>

<Info>
  **Permission Provider Integration**

  This API is used in conjunction with the [Permission Provider configuration mode](/key-concepts/overview#c-real-time-permission-provider). When implementing your backend Permission Provider endpoint, use this endpoint to generate a secure signature for your permission response.
</Info>

# Endpoint

`POST https://api.velt.dev/v2/auth/generate_signature`

# Headers

<ParamField header="x-velt-api-key" type="string" required>
  Your API key.
</ParamField>

<ParamField header="x-velt-auth-token" type="string" required>
  Your [Auth Token](/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="permissions" type="PermissionData[]" required>
      Array of permission decisions to sign. Each object must include user ID, resource information, access decision, and optional role/expiration.

      <Expandable title="PermissionData Object Properties">
        <ParamField body="userId" type="string" required>
          ID of the user this permission applies to.
        </ParamField>

        <ParamField body="resourceId" type="string" required>
          ID of the resource (document, folder, or organization).
        </ParamField>

        <ParamField body="type" type="string" required>
          Type of the resource. Allowed values: `"document"` | `"folder"` | `"organization"`.
        </ParamField>

        <ParamField body="hasAccess" type="boolean" required>
          Whether the user has access to the resource.
        </ParamField>

        <ParamField body="accessRole" type="string">
          Access role for the user. Only applicable for document resources. Allowed values: `"viewer"` | `"editor"`. `viewer` can view and comment, `editor` can edit content.
        </ParamField>

        <ParamField body="expiresAt" type="number">
          UTC timestamp in milliseconds when this permission expires. Velt will revalidate access after expiration.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## **Example Requests**

#### 1. Generate signature for document access with viewer role and expiration

```JSON theme={null}
{
  "data": {
    "permissions": [
      {
        "userId": "user123",
        "resourceId": "document456",
        "type": "document",
        "hasAccess": true,
        "accessRole": "viewer",
        "expiresAt": 1759745729823
      }
    ]
  }
}
```

#### 2. Generate signature for multiple resources (organization and folder)

```JSON theme={null}
{
  "data": {
    "permissions": [
      {
        "userId": "user123",
        "resourceId": "org789",
        "type": "organization",
        "hasAccess": true
      },
      {
        "userId": "user123",
        "resourceId": "folder101",
        "type": "folder",
        "hasAccess": true
      }
    ]
  }
}
```

#### 3. Generate signature denying access

```JSON theme={null}
{
  "data": {
    "permissions": [
      {
        "userId": "user456",
        "resourceId": "document789",
        "type": "document",
        "hasAccess": false
      }
    ]
  }
}
```

#### 4. Generate signature for document with editor role

```JSON theme={null}
{
  "data": {
    "permissions": [
      {
        "userId": "user789",
        "resourceId": "document123",
        "type": "document",
        "hasAccess": true,
        "accessRole": "editor"
      }
    ]
  }
}
```

#### 5. Generate signature for document with viewer role

```JSON theme={null}
{
  "data": {
    "permissions": [
      {
        "userId": "user456",
        "resourceId": "document123",
        "type": "document",
        "hasAccess": true,
        "accessRole": "viewer"
      }
    ]
  }
}
```

# Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "Signature generated successfully.",
    "data": {
      "signature": "a1b2c3d4e5f6..."
    }
  }
}
```

#### Failure Response

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
```

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "Signature generated successfully.",
      "data": {
        "signature": "a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890"
      }
    }
  }
  ```
</ResponseExample>
