POST
/
v2
/
authentication
/
generate_token
Generate Token
curl --request POST \
  --url https://api.velt.dev/v2/authentication/generate_token \
  --header 'Content-Type: application/json' \
  --header 'x-velt-api-key: <x-velt-api-key>' \
  --header 'x-velt-auth-token: <x-velt-auth-token>' \
  --data '{
  "userId": "<string>",
  "userProperties": {
    "isAdmin": true,
    "name": "<string>",
    "email": "<string>"
  },
  "permissions": {
    "resources": [
      {
        "type": "<string>",
        "id": "<string>",
        "organizationId": "<string>",
        "expiresAt": 123
      }
    ]
  }
}'
{
  "result": {
    "status": "success",
    "message": "Token generated successfully.",
    "data": {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c2VyMTIzIiwiaWF0IjoxNjQwOTk1MjAwfQ.signature"
    }
  }
}
Use this API to generate authentication JWT token for users to access Velt features. The token contains user information and permissions for specific resources like organizations, folders and documents.
  • JWT token expires in 48 hours.
  • You can specify permissions for different resource types (organization, folder, document)

Endpoint

POST https://api.velt.dev/v2/authentication/generate_token

Headers

x-velt-api-key
string
required
Your API key.
x-velt-auth-token
string
required

Body

Params

userId
string
required
Unique identifier for the user.
userProperties
object
required
permissions
object
required

Example Requests

1. Generate token with organization and document permissions

{
  "userId": "user123",
  "userProperties": {
    "isAdmin": false,
    "name": "John Doe",
    "email": "john@example.com"
  },
  "permissions": {
    "resources": [
      {
        "type": "organization",
        "id": "org_123"
      },
      {
        "type": "document",
        "id": "doc_456",
        "organizationId": "org_123",
        "expiresAt": 1640995200
      }
    ]
  }
}

2. Generate token with only organization access

{
  "userId": "user456",
  "userProperties": {
    "isAdmin": true,
    "name": "Jane Smith",
    "email": "jane@example.com"
  },
  "permissions": {
    "resources": [
      {
        "type": "organization",
        "id": "org_789"
      }
    ]
  }
}

3. Generate token with folder permissions

{
  "userId": "user789",
  "userProperties": {
    "isAdmin": false,
    "name": "Bob Wilson",
    "email": "bob@example.com"
  },
  "permissions": {
    "resources": [
      {
        "type": "organization",
        "id": "org_123"
      },
      {
        "type": "folder",
        "id": "folder_001",
        "organizationId": "org_123"
      }
    ]
  }
}

Response

Success Response

{
  "result": {
    "status": "success",
    "message": "Token generated successfully.",
    "data": {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
    }
  }
}

Failure Response

{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
{
  "result": {
    "status": "success",
    "message": "Token generated successfully.",
    "data": {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c2VyMTIzIiwiaWF0IjoxNjQwOTk1MjAwfQ.signature"
    }
  }
}