> ## 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.

> [!NOTE]
>
> **Permission Provider Integration**
>
> This API is used in conjunction with the [Permission Provider configuration mode](https://velt.dev/docs/key-concepts/overview.md#c-real-time-permission-provider). When implementing your backend Permission Provider endpoint, use this endpoint to generate a secure signature for your permission response.

# Endpoint

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

# Headers

**x-velt-api-key** `string` *required*

Your API key.

**x-velt-auth-token** `string` *required*

Your [Auth Token](https://velt.dev/docs/security/auth-tokens.md).

# Body

#### Params

**data** `object` *required*

**properties**

**permissions** `PermissionData[]` *required*

Array of permission decisions to sign. Each object must include user ID, resource information, access decision, and optional role/expiration.

**PermissionData Object Properties**

**userId** `string` *required*

ID of the user this permission applies to.

**resourceId** `string` *required*

ID of the resource (document, folder, or organization).

**type** `string` *required*

Type of the resource. Allowed values: `"document"` | `"folder"` | `"organization"`.

**hasAccess** `boolean` *required*

Whether the user has access to the resource.

**accessRole** `string`

Access role for the user. Only applicable for document resources. Allowed values: `"viewer"` | `"editor"`. `viewer` can view and comment, `editor` can edit content.

**expiresAt** `number`

UTC timestamp in milliseconds when this permission expires. Velt will revalidate access after expiration.

## **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"
  }
}
```

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.