List the custom fields
GET
/v1/fieldsThe custom fields of the account in their order: key — the variable {{key}} of templates and the key in the fields of a contact; type — text, number, money (in the account currency) or date; fallback — what a contact without a value gets when the text has no fallback (null — none). Keys with the contacts permission.
API key permission: contacts · Limit: 20 requests a second per key
Request
bash
curl "https://api.ace-send.com/v1/fields" \
-H "Authorization: Bearer ak_live_YOUR_API_KEY"js
const response = await fetch('https://api.ace-send.com/v1/fields', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.ACE_SEND_API_KEY}`,
},
})
const result = await response.json()
if (!response.ok) {
// application/problem+json: result.code is stable, result.title is for people
throw new Error(`${result.code}: ${result.title}`)
}
console.log(result)python
import os
import requests
headers = {
"Authorization": f"Bearer {os.environ['ACE_SEND_API_KEY']}",
}
response = requests.get(
"https://api.ace-send.com/v1/fields",
headers=headers,
timeout=10,
)
result = response.json()
if not response.ok:
# application/problem+json: result["code"] is stable, result["title"] is for people
raise RuntimeError(f"{result['code']}: {result['title']}")
print(result)php
<?php
// composer require guzzlehttp/guzzle
$client = new GuzzleHttp\Client(['base_uri' => 'https://api.ace-send.com/v1/']);
$response = $client->request('GET', 'fields', [
'headers' => [
'Authorization' => 'Bearer '.getenv('ACE_SEND_API_KEY'),
],
'http_errors' => false,
]);
$result = json_decode((string) $response->getBody(), true);
if ($response->getStatusCode() >= 400) {
// application/problem+json: $result['code'] is stable, $result['title'] is for people
throw new RuntimeException($result['code'].': '.$result['title']);
}
print_r($result);Response
200 OK
| Field | Type | Description |
|---|---|---|
data | object[] | |
data[].key | string | |
data[].label | string | |
data[].type | string | One of: text, number, money, date. |
data[].fallback | string, nullable |
json
{
"data": [
{
"key": "promo_code",
"label": "Promo code",
"type": "text",
"fallback": "BONUS10"
},
{
"key": "amount",
"label": "Deposit amount",
"type": "money",
"fallback": null
},
{
"key": "last_deposit",
"label": "Last deposit",
"type": "money",
"fallback": null
},
{
"key": "days_idle",
"label": "Days idle",
"type": "number",
"fallback": null
},
{
"key": "vip_since",
"label": "VIP since",
"type": "date",
"fallback": null
}
]
}Errors
Errors are application/problem+json with a stable code (all codes). Besides the errors of every request (an invalid key, a missing permission, too many requests), this endpoint answers:
| Status | Code | Meaning |
|---|---|---|
| 401 | api_key_invalid | No Authorization: Bearer header, or the key is unknown or revoked. After 20 failed key checks in a minute the address gets too_many_requests for the rest of the minute. |
| 403 | api_key_ip_denied | The key has an IP allowlist and the request came from another address. |
| 403 | account_suspended | The account is suspended. Contact support. |
| 403 | api_key_scope | The key lacks the permission of the endpoint (send, status or contacts). |
| 429 | too_many_requests | Over the rate limit. Wait for the seconds of the Retry-After header. |