Link Document to Entity
curl --request POST \
--url https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entity_type": "<string>",
"entity_id": "<string>",
"role": "<string>"
}
'import requests
url = "https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link"
payload = {
"entity_type": "<string>",
"entity_id": "<string>",
"role": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({entity_type: '<string>', entity_id: '<string>', role: '<string>'})
};
fetch('https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'entity_type' => '<string>',
'entity_id' => '<string>',
'role' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link"
payload := strings.NewReader("{\n \"entity_type\": \"<string>\",\n \"entity_id\": \"<string>\",\n \"role\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entity_type\": \"<string>\",\n \"entity_id\": \"<string>\",\n \"role\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"entity_type\": \"<string>\",\n \"entity_id\": \"<string>\",\n \"role\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"link_id": "<string>",
"document_id": "<string>",
"entity_type": "<string>",
"entity_id": "<string>",
"role": "<string>",
"created_at": "<string>"
}
}Documents
Link Document to Entity
Attach a document to a contact, company, deal, event, matter, or task
POST
/
v1
/
documents
/
{id}
/
link
Link Document to Entity
curl --request POST \
--url https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"entity_type": "<string>",
"entity_id": "<string>",
"role": "<string>"
}
'import requests
url = "https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link"
payload = {
"entity_type": "<string>",
"entity_id": "<string>",
"role": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({entity_type: '<string>', entity_id: '<string>', role: '<string>'})
};
fetch('https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'entity_type' => '<string>',
'entity_id' => '<string>',
'role' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link"
payload := strings.NewReader("{\n \"entity_type\": \"<string>\",\n \"entity_id\": \"<string>\",\n \"role\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"entity_type\": \"<string>\",\n \"entity_id\": \"<string>\",\n \"role\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://data.leadlex.com/functions/v1/api-gateway/v1/documents/{id}/link")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"entity_type\": \"<string>\",\n \"entity_id\": \"<string>\",\n \"role\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"link_id": "<string>",
"document_id": "<string>",
"entity_type": "<string>",
"entity_id": "<string>",
"role": "<string>",
"created_at": "<string>"
}
}Request
Path Parameters
Headers
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
Body Parameters
Optional relationship label (e.g.
signed, draft, evidence). Free-form string, max 64 characters.Response
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"
}'
import requests
API_KEY = "wbk_your_api_key_here"
BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"
doc_id = "doc_01HY1"
r = requests.post(
f"{BASE_URL}/v1/documents/{doc_id}/link",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"entity_type": "deal",
"entity_id": "deal_01HY1",
"role": "signed",
},
)
print(r.json()["data"]["link_id"])
const docId = 'doc_01HY1';
const res = await fetch(
`https://data.leadlex.com/functions/v1/api-gateway/v1/documents/${docId}/link`,
{
method: 'POST',
headers: {
'Authorization': 'Bearer wbk_your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
entity_type: 'deal',
entity_id: 'deal_01HY1',
role: 'signed',
}),
}
);
const { data } = await res.json();
console.log(data.link_id);
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
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Unsupported entity_type or missing entity_id |
| 401 | invalid_key | Invalid or expired API key |
| 403 | insufficient_permissions | Missing write:documents permission |
| 404 | not_found | Document or entity does not exist |
| 429 | rate_limited | Rate limit exceeded |