Update an account
curl --request PATCH \
--url https://{dsn}/api/v1/accounts/{account_id} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"metadata": {
"crm_id": "42",
"team": "sales"
}
}
'import requests
url = "https://{dsn}/api/v1/accounts/{account_id}"
payload = { "metadata": {
"crm_id": "42",
"team": "sales"
} }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({metadata: {crm_id: '42', team: 'sales'}})
};
fetch('https://{dsn}/api/v1/accounts/{account_id}', 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://{dsn}/api/v1/accounts/{account_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'crm_id' => '42',
'team' => 'sales'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://{dsn}/api/v1/accounts/{account_id}"
payload := strings.NewReader("{\n \"metadata\": {\n \"crm_id\": \"42\",\n \"team\": \"sales\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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.patch("https://{dsn}/api/v1/accounts/{account_id}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"crm_id\": \"42\",\n \"team\": \"sales\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{dsn}/api/v1/accounts/{account_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"crm_id\": \"42\",\n \"team\": \"sales\"\n }\n}"
response = http.request(request)
puts response.read_body{
"object": "Account",
"id": "<string>",
"user_id": "<string>",
"name": "<string>",
"provider": "imap",
"status": "running",
"status_detail": "<string>",
"is_locked": true,
"initial_sync": {
"status": "pending",
"started_at": "2023-11-07T05:31:56Z",
"completed_at": "2023-11-07T05:31:56Z",
"days": 15,
"imported": 123
},
"metadata": {},
"connection_params": {},
"created_at": "2023-11-07T05:31:56Z",
"last_synced_at": "2023-11-07T05:31:56Z"
}{
"status": 400,
"type": "errors/invalid_parameters",
"title": "Invalid parameters",
"detail": "limit must be between 1 and 250"
}{
"status": 401,
"type": "errors/unauthorized",
"title": "Unauthorized",
"detail": "missing or invalid API key"
}{
"status": 404,
"type": "errors/not_found",
"title": "Not found",
"detail": "email email_94a0d77db739407e932c3b97fef44aac not found"
}Accounts
Update an account
Sets your own key-value metadata on the account, for example the user’s id in your app.
The object you send replaces the current metadata. Values must be strings.
PATCH
/
accounts
/
{account_id}
Update an account
curl --request PATCH \
--url https://{dsn}/api/v1/accounts/{account_id} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"metadata": {
"crm_id": "42",
"team": "sales"
}
}
'import requests
url = "https://{dsn}/api/v1/accounts/{account_id}"
payload = { "metadata": {
"crm_id": "42",
"team": "sales"
} }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({metadata: {crm_id: '42', team: 'sales'}})
};
fetch('https://{dsn}/api/v1/accounts/{account_id}', 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://{dsn}/api/v1/accounts/{account_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'crm_id' => '42',
'team' => 'sales'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://{dsn}/api/v1/accounts/{account_id}"
payload := strings.NewReader("{\n \"metadata\": {\n \"crm_id\": \"42\",\n \"team\": \"sales\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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.patch("https://{dsn}/api/v1/accounts/{account_id}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"crm_id\": \"42\",\n \"team\": \"sales\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{dsn}/api/v1/accounts/{account_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {\n \"crm_id\": \"42\",\n \"team\": \"sales\"\n }\n}"
response = http.request(request)
puts response.read_body{
"object": "Account",
"id": "<string>",
"user_id": "<string>",
"name": "<string>",
"provider": "imap",
"status": "running",
"status_detail": "<string>",
"is_locked": true,
"initial_sync": {
"status": "pending",
"started_at": "2023-11-07T05:31:56Z",
"completed_at": "2023-11-07T05:31:56Z",
"days": 15,
"imported": 123
},
"metadata": {},
"connection_params": {},
"created_at": "2023-11-07T05:31:56Z",
"last_synced_at": "2023-11-07T05:31:56Z"
}{
"status": 400,
"type": "errors/invalid_parameters",
"title": "Invalid parameters",
"detail": "limit must be between 1 and 250"
}{
"status": 401,
"type": "errors/unauthorized",
"title": "Unauthorized",
"detail": "missing or invalid API key"
}{
"status": 404,
"type": "errors/not_found",
"title": "Not found",
"detail": "email email_94a0d77db739407e932c3b97fef44aac not found"
}Authorizations
Your access token, from your dashboard under API keys.
Path Parameters
The account's acc_… id.
Body
application/json
Your own key-value data.
Show child attributes
Show child attributes
Example:
{ "crm_id": "42", "team": "sales" }
Response
The updated account.
Allowed value:
"Account"acc_…
The mailbox's email address.
imap: Gmail, Google Workspace and every other provider through IMAP/SMTP.
Available options:
imap running: connected and syncing.errored: syncing keeps failing (server down, network); the engine retries by itself.disconnected: the provider rejected the password or token (reconnect it), or the account is paused in the dashboard (is_locked: true).
Available options:
running, errored, disconnected The last error message
Paused from the dashboard: not syncing.
Only on accounts connected with initial_sync_enable: true: the import of the mail already in the mailbox.
Show child attributes
Show child attributes
Your own key-value data.
Show child attributes
Show child attributes
Connection settings, never passwords.