Add a contact to a list, single or double opt-in
# REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:edit.# Replace reputecast.example.com with your public URL, your-workspace with your workspace slug# and the list ID with one from GET /api/v1/workspaces/your-workspace/lists.curl --request POST \ --url https://reputecast.example.com/api/v1/workspaces/your-workspace/lists/0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f/contacts \ --header "Authorization: Bearer $REPUTECAST_API_KEY" \ --header 'Content-Type: application/json' \ --data '{ "email": "sam.rivera@outlook.com", "consent": "single" }'// REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:edit.// Replace reputecast.example.com with your public URL, your-workspace with your workspace slug// and the list ID with one from GET /api/v1/workspaces/your-workspace/lists.const listId = '0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f'const response = await fetch( `https://reputecast.example.com/api/v1/workspaces/your-workspace/lists/${listId}/contacts`, { method: 'POST', headers: { Authorization: `Bearer ${process.env.REPUTECAST_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ email: 'sam.rivera@outlook.com', consent: 'single' }), },)const result = await response.json()// 404: no contact with that address (create it with upsert-contact first).// 409 unsubscribed or suppressed: the contact left the list or the address is suppressed, so it is not added back.if (!response.ok) throw new Error(`${response.status} ${result.code}: ${result.detail}`)console.log(result.contactId, result.lists)// REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:edit.// Replace reputecast.example.com with your public URL, your-workspace with your workspace slug// and the list ID with one from GET /api/v1/workspaces/your-workspace/lists.package main
import ( "bytes" "encoding/json" "fmt" "log" "net/http" "os")
func main() { listID := "0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f" body, err := json.Marshal(map[string]string{"email": "sam.rivera@outlook.com", "consent": "single"}) if err != nil { log.Fatal(err) } req, err := http.NewRequest(http.MethodPost, "https://reputecast.example.com/api/v1/workspaces/your-workspace/lists/"+listID+"/contacts", bytes.NewReader(body)) if err != nil { log.Fatal(err) } req.Header.Set("Authorization", "Bearer "+os.Getenv("REPUTECAST_API_KEY")) req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close()
var result struct { ContactID string `json:"contactId"` Lists []struct { Name string `json:"name"` Status string `json:"status"` } `json:"lists"` Code string `json:"code"` Detail string `json:"detail"` } if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { log.Fatal(err) } // 404: no contact with that address (create it with upsert-contact first). // 409 unsubscribed or suppressed: the contact left the list or the address is suppressed, so it is not added back. if resp.StatusCode >= 300 { log.Fatalf("%d %s: %s", resp.StatusCode, result.Code, result.Detail) } fmt.Println(result.ContactID, result.Lists)}# REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:edit.# Replace reputecast.example.com with your public URL, your-workspace with your workspace slug# and the list ID with one from GET /api/v1/workspaces/your-workspace/lists.import os
import requests
list_id = "0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f"response = requests.post( f"https://reputecast.example.com/api/v1/workspaces/your-workspace/lists/{list_id}/contacts", headers={"Authorization": f"Bearer {os.environ['REPUTECAST_API_KEY']}"}, json={"email": "sam.rivera@outlook.com", "consent": "single"}, timeout=10,)result = response.json()# 404: no contact with that address (create it with upsert-contact first).# 409 unsubscribed or suppressed: the contact left the list or the address is suppressed, so it is not added back.if not response.ok: raise RuntimeError(f"{response.status_code} {result.get('code')}: {result.get('detail')}")print(result["contactId"], result["lists"])<?php// REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:edit.// Replace reputecast.example.com with your public URL, your-workspace with your workspace slug// and the list ID with one from GET /api/v1/workspaces/your-workspace/lists.$listId = '0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f';$payload = ['email' => 'sam.rivera@outlook.com', 'consent' => 'single'];
$ch = curl_init("https://reputecast.example.com/api/v1/workspaces/your-workspace/lists/{$listId}/contacts");curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . getenv('REPUTECAST_API_KEY'), 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR),]);$body = curl_exec($ch);if ($body === false) { throw new RuntimeException(curl_error($ch));}$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);$result = json_decode($body, true, flags: JSON_THROW_ON_ERROR);// 404: no contact with that address (create it with upsert-contact first).// 409 unsubscribed or suppressed: the contact left the list or the address is suppressed, so it is not added back.if ($status >= 300) { throw new RuntimeException("{$status} {$result['code']}: {$result['detail']}");}echo $result['contactId'], PHP_EOL;Permission: subscribers:edit
Never adds someone back to a list they left, or a suppressed address: both answer 409 with the date and the reason.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Workspace slug
Workspace slug
The list
The list
Request Bodyrequired
Section titled “Request Bodyrequired”object
Responses
Section titled “Responses”OK
object
object
Example
{ "lists": [ { "status": "subscribed" } ]}default
Section titled “default”Error
object
Stable error code, e.g. permission_denied
A human-readable explanation specific to this occurrence of the problem.
Optional list of individual error details
object
Where the error occurred, e.g. ‘body.items[3].tags’ or ‘path.thing-id’
Error message text
The value at the given location
Members who hold the missing permission
A URI reference that identifies the specific occurrence of the problem.
object
The missing permission key
HTTP status code
A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
A URI reference to human-readable documentation for the error.
Example
{ "detail": "Property foo is required but is missing.", "instance": "https://example.com/error-log/abc123", "status": 400, "title": "Bad Request", "type": "about:blank"}