Skip to main content
POST
/
v1
/
documents
/
{id}
/
link
Link Document to Entity
curl --request POST \
  --url https://api.example.com/v1/documents/{id}/link \
  --header 'Content-Type: application/json' \
  --data '
{
  "entity_type": "<string>",
  "entity_id": "<string>",
  "role": "<string>"
}
'
{
  "data": {
    "link_id": "<string>",
    "document_id": "<string>",
    "entity_type": "<string>",
    "entity_id": "<string>",
    "role": "<string>",
    "created_at": "<string>"
  }
}

Request

Path Parameters

id
string
required
Document UUID.

Headers

Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
Idempotency-Key
string
Optional UUID for retry deduplication.

Body Parameters

entity_type
string
required
One of contact, company, deal, event, matter, or task.
entity_id
string
required
UUID of the target entity.
role
string
Optional relationship label (e.g. signed, draft, evidence). Free-form string, max 64 characters.

Response

data
object
A document may be linked to multiple entities simultaneously; the same (document_id, entity_type, entity_id) triple returns the existing link rather than creating duplicates. Responses include X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-Request-ID.
curl -X POST \
  https://data.leadlex.com/functions/v1/api-gateway/v1/documents/doc_01HY1/link \
  -H "Authorization: Bearer wbk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "entity_type": "contact",
    "entity_id": "123e4567-e89b-12d3-a456-426614174000",
    "role": "signed"
  }'

Example Response

{
  "data": {
    "link_id": "dlnk_01HY1",
    "document_id": "doc_01HY1",
    "entity_type": "deal",
    "entity_id": "deal_01HY1",
    "role": "signed",
    "created_at": "2026-04-17T10:55:00Z"
  }
}

Errors

StatusCodeDescription
400validation_errorUnsupported entity_type or missing entity_id
401invalid_keyInvalid or expired API key
403insufficient_permissionsMissing write:documents permission
404not_foundDocument or entity does not exist
429rate_limitedRate limit exceeded