Create API key
curl --request POST \
--url https://api.naturalead.ai/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production CRM sync",
"scopes": [
"leads:view",
"leads:import",
"conversations:view"
],
"expiresAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.naturalead.ai/api/api-keys"
payload = {
"name": "Production CRM sync",
"scopes": ["leads:view", "leads:import", "conversations:view"],
"expiresAt": "2023-11-07T05:31:56Z"
}
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({
name: 'Production CRM sync',
scopes: ['leads:view', 'leads:import', 'conversations:view'],
expiresAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.naturalead.ai/api/api-keys', 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://api.naturalead.ai/api/api-keys",
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([
'name' => 'Production CRM sync',
'scopes' => [
'leads:view',
'leads:import',
'conversations:view'
],
'expiresAt' => '2023-11-07T05:31:56Z'
]),
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://api.naturalead.ai/api/api-keys"
payload := strings.NewReader("{\n \"name\": \"Production CRM sync\",\n \"scopes\": [\n \"leads:view\",\n \"leads:import\",\n \"conversations:view\"\n ],\n \"expiresAt\": \"2023-11-07T05:31:56Z\"\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://api.naturalead.ai/api/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production CRM sync\",\n \"scopes\": [\n \"leads:view\",\n \"leads:import\",\n \"conversations:view\"\n ],\n \"expiresAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.naturalead.ai/api/api-keys")
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 \"name\": \"Production CRM sync\",\n \"scopes\": [\n \"leads:view\",\n \"leads:import\",\n \"conversations:view\"\n ],\n \"expiresAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"apiKey": {
"_id": "<string>",
"name": "<string>",
"keyPrefix": "<string>",
"keyHint": "<string>",
"scopes": [
"<string>"
],
"environment": "live",
"status": "active",
"createdAt": "2023-11-07T05:31:56Z",
"accountId": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z"
},
"fullKey": "nl_live_a1b2c3d4e5f6..."
}{
"error": "<string>"
}{
"error": "<string>"
}API Keys
Create API Key
Creates a new API key for the current account. The full key is returned
only once in the response and is never stored or retrievable again.
The key creator can only grant scopes (permissions) that they themselves hold.
Requires api_keys:manage permission.
POST
/
api
/
api-keys
Create API key
curl --request POST \
--url https://api.naturalead.ai/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production CRM sync",
"scopes": [
"leads:view",
"leads:import",
"conversations:view"
],
"expiresAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.naturalead.ai/api/api-keys"
payload = {
"name": "Production CRM sync",
"scopes": ["leads:view", "leads:import", "conversations:view"],
"expiresAt": "2023-11-07T05:31:56Z"
}
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({
name: 'Production CRM sync',
scopes: ['leads:view', 'leads:import', 'conversations:view'],
expiresAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.naturalead.ai/api/api-keys', 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://api.naturalead.ai/api/api-keys",
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([
'name' => 'Production CRM sync',
'scopes' => [
'leads:view',
'leads:import',
'conversations:view'
],
'expiresAt' => '2023-11-07T05:31:56Z'
]),
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://api.naturalead.ai/api/api-keys"
payload := strings.NewReader("{\n \"name\": \"Production CRM sync\",\n \"scopes\": [\n \"leads:view\",\n \"leads:import\",\n \"conversations:view\"\n ],\n \"expiresAt\": \"2023-11-07T05:31:56Z\"\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://api.naturalead.ai/api/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production CRM sync\",\n \"scopes\": [\n \"leads:view\",\n \"leads:import\",\n \"conversations:view\"\n ],\n \"expiresAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.naturalead.ai/api/api-keys")
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 \"name\": \"Production CRM sync\",\n \"scopes\": [\n \"leads:view\",\n \"leads:import\",\n \"conversations:view\"\n ],\n \"expiresAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"apiKey": {
"_id": "<string>",
"name": "<string>",
"keyPrefix": "<string>",
"keyHint": "<string>",
"scopes": [
"<string>"
],
"environment": "live",
"status": "active",
"createdAt": "2023-11-07T05:31:56Z",
"accountId": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z"
},
"fullKey": "nl_live_a1b2c3d4e5f6..."
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Bearer token using an API key (format nl_live_* or nl_test_*)
Body
application/json
Human-readable name for the key
Example:
"Production CRM sync"
RBAC permissions to grant to this key. Must be a subset of the creator's own permissions.
Example:
[
"leads:view",
"leads:import",
"conversations:view"
]
Key environment (affects key prefix nl_live_ or nl_test_)
Available options:
live, test Optional expiration date (must be in the future)