ZapSMTP / Docs / VariablesResponse
Set a global variable
PUT/v1/variables/global/{key}
Create or replace a global variable. Every template that uses it renders the new value from the next send on.
Requires a full-access live key; test keys get 403 test_key_restricted.
The response does not list the templates using the variable; GET /variables does.
Path parameters
keystringrequired- The key, used as
{{global.key}}: letters, digits,_and-, starting with a letter or_, up to 64;globalis reserved. Limits: other keys → 422 invalid_parameter
Body parameters
valuestring- The value, always a string. Limits: at most 10 KB → 422 invalid_parameter Default
"". descriptionstring- What it is for. Limits: at most 500 bytes → 422 invalid_parameter
Errors
restricted_api_keyHTTP 403test_key_restrictedHTTP 403- test-mode keys can send test email and read, not change the account: use a live key
invalid_parameterHTTP 422- bad key, value over 10 KB or description over 500 bytes
curl -X PUT 'https://zapsmtp.xyz/v1/variables/global/company_name' \
-H "Authorization: Bearer $ZAP_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"value": "Acme Inc.",
"description": "Legal name for footers"
}'const res = await fetch('https://zapsmtp.xyz/v1/variables/global/company_name', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.ZAP_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"value": "Acme Inc.",
"description": "Legal name for footers"
}),
});
// 204 No Content (e.g. a delete) has no body
const data = res.status === 204 ? null : await res.json();
if (!res.ok) throw new Error(`${data.name}: ${data.message}`);
console.log(data);import os
import requests
res = requests.put(
"https://zapsmtp.xyz/v1/variables/global/company_name",
headers={"Authorization": f"Bearer {os.environ['ZAP_API_KEY']}"},
json={
"value": "Acme Inc.",
"description": "Legal name for footers",
},
timeout=30,
)
res.raise_for_status()
print(res.json() if res.status_code != 204 else "deleted")<?php
$ch = curl_init('https://zapsmtp.xyz/v1/variables/global/company_name');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ZAP_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'value' => 'Acme Inc.',
'description' => 'Legal name for footers',
]),
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status >= 400) {
throw new RuntimeException($data['message']);
}
print_r($data);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"value": "Acme Inc.",
"description": "Legal name for footers"
}`)
req, err := http.NewRequest(
"PUT",
"https://zapsmtp.xyz/v1/variables/global/company_name",
body,
)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("ZAP_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(out))
}require 'net/http'
require 'json'
uri = URI('https://zapsmtp.xyz/v1/variables/global/company_name')
req = Net::HTTP::Put.new(uri)
req['Authorization'] = "Bearer #{ENV.fetch('ZAP_API_KEY')}"
req['Content-Type'] = 'application/json'
req.body = {
value: "Acme Inc.",
description: "Legal name for footers"
}.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.code, (JSON.parse(res.body) unless res.body.to_s.empty?)import java.net.URI;
import java.net.http.*;
public class ZapRequest {
public static void main(String[] args) throws Exception {
var request = HttpRequest.newBuilder(URI.create("https://zapsmtp.xyz/v1/variables/global/company_name"))
.header("Authorization", "Bearer " + System.getenv("ZAP_API_KEY"))
.header("Content-Type", "application/json")
.method("PUT", HttpRequest.BodyPublishers.ofString("""
{
"value": "Acme Inc.",
"description": "Legal name for footers"
}"""))
.build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}using System.Net.Http.Headers;
using System.Text;
using var http = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://zapsmtp.xyz/v1/variables/global/company_name");
request.Headers.Authorization = new AuthenticationHeaderValue(
"Bearer", Environment.GetEnvironmentVariable("ZAP_API_KEY"));
request.Content = new StringContent("""
{
"value": "Acme Inc.",
"description": "Legal name for footers"
}
""", Encoding.UTF8, "application/json");
var response = await http.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");Set
ZAP_API_KEY in your environment.Response 200 OK
{
"object": "variable",
"name": "global.company_name",
"kind": "global",
"type": "string",
"key": "company_name",
"value": "Acme Inc.",
"description": "Legal name for footers",
"updated_at": "2026-10-27T10:30:00Z",
"templates": []
}