Create or update a contact, matched by email
# REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:create (and subscribers:edit to update contacts).# Replace reputecast.example.com with your public URL and your-workspace with your workspace slug.# List IDs come from GET /api/v1/workspaces/your-workspace/lists.curl --request POST \ --url https://reputecast.example.com/api/v1/workspaces/your-workspace/contacts/upsert \ --header "Authorization: Bearer $REPUTECAST_API_KEY" \ --header 'Content-Type: application/json' \ --data '{ "email": "sam.rivera@outlook.com", "firstName": "Sam", "lastName": "Rivera", "language": "en-US", "tags": ["trial"], "lists": ["0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f"], "consent": "double" }'// REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:create (and subscribers:edit to update contacts).// Replace reputecast.example.com with your public URL and your-workspace with your workspace slug.// List IDs come from GET /api/v1/workspaces/your-workspace/lists.const response = await fetch('https://reputecast.example.com/api/v1/workspaces/your-workspace/contacts/upsert', { method: 'POST', headers: { Authorization: `Bearer ${process.env.REPUTECAST_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ email: 'sam.rivera@outlook.com', firstName: 'Sam', lastName: 'Rivera', language: 'en-US', tags: ['trial'], lists: ['0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f'], consent: 'double', // sends a confirmation email before the contact joins the list }),})const result = await response.json()// 409 unsubscribed or suppressed: the address left that list or 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.created ? 'created' : 'updated', result.lists)// REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:create (and subscribers:edit to update contacts).// Replace reputecast.example.com with your public URL and your-workspace with your workspace slug.// List IDs come from GET /api/v1/workspaces/your-workspace/lists.package main
import ( "bytes" "encoding/json" "fmt" "log" "net/http" "os")
func main() { body, err := json.Marshal(map[string]any{ "email": "sam.rivera@outlook.com", "firstName": "Sam", "lastName": "Rivera", "language": "en-US", "tags": []string{"trial"}, "lists": []string{"0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f"}, "consent": "double", // sends a confirmation email before the contact joins the list }) if err != nil { log.Fatal(err) } req, err := http.NewRequest(http.MethodPost, "https://reputecast.example.com/api/v1/workspaces/your-workspace/contacts/upsert", 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"` Created bool `json:"created"` 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) } // 409 unsubscribed or suppressed: the address left that list or 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.Created, result.Lists)}# REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:create (and subscribers:edit to update contacts).# Replace reputecast.example.com with your public URL and your-workspace with your workspace slug.# List IDs come from GET /api/v1/workspaces/your-workspace/lists.import os
import requests
response = requests.post( "https://reputecast.example.com/api/v1/workspaces/your-workspace/contacts/upsert", headers={"Authorization": f"Bearer {os.environ['REPUTECAST_API_KEY']}"}, json={ "email": "sam.rivera@outlook.com", "firstName": "Sam", "lastName": "Rivera", "language": "en-US", "tags": ["trial"], "lists": ["0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f"], "consent": "double", # sends a confirmation email before the contact joins the list }, timeout=10,)result = response.json()# 409 unsubscribed or suppressed: the address left that list or 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"], "created" if result["created"] else "updated", result["lists"])<?php// REPUTECAST_API_KEY: an API key (rc_live_…) with subscribers:create (and subscribers:edit to update contacts).// Replace reputecast.example.com with your public URL and your-workspace with your workspace slug.// List IDs come from GET /api/v1/workspaces/your-workspace/lists.$payload = [ 'email' => 'sam.rivera@outlook.com', 'firstName' => 'Sam', 'lastName' => 'Rivera', 'language' => 'en-US', 'tags' => ['trial'], 'lists' => ['0192f1c4-3a5b-7c2d-8e9f-1a2b3c4d5e6f'], 'consent' => 'double', // sends a confirmation email before the contact joins the list];
$ch = curl_init('https://reputecast.example.com/api/v1/workspaces/your-workspace/contacts/upsert');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);// 409 unsubscribed or suppressed: the address left that list or is suppressed, so it is not added back.if ($status >= 300) { throw new RuntimeException("{$status} {$result['code']}: {$result['detail']}");}echo $result['contactId'], ' ', $result['created'] ? 'created' : 'updated', PHP_EOL;Permission: subscribers:create
Adds to lists with single or double opt-in. Never adds someone back to a list they left (409 unsubscribed) or a suppressed address (409 suppressed). Updating an existing contact needs subscribers:edit.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Workspace slug
Workspace slug
Request Bodyrequired
Section titled “Request Bodyrequired”object
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"}