### GET Campaign Metrics Request Example Source: https://developers.sparkpost.com/api/metrics This example shows how to request aggregate metrics grouped by campaign over a specified time window. Ensure the 'from' parameter is set to a valid datetime and 'metrics' is provided. ```http GET /api/v1/metrics/deliverability/template?from=2018-07-11T08:00&limit=5&order_by=count_injected ``` -------------------------------- ### Resource Not Found Error Example Source: https://developers.sparkpost.com/api/sending-domains Example JSON response when a requested sending domain resource is not found. ```JSON { "errors": [ { "code": "1600", "message": "resource not found", "description": "Domain 'example.com' does not exist" } ] } ``` -------------------------------- ### GET Request for Subject Campaign Metrics Source: https://developers.sparkpost.com/api/metrics Example of a GET request to retrieve deliverability metrics for subject campaigns. Includes parameters for time range and ordering. ```bash GET /api/v1/metrics/deliverability/subject-campaign?from=2018-07-11T08:00&limit=5&order_by=count_injected ``` -------------------------------- ### Example API Request and Response for Mailbox Provider Metrics Source: https://developers.sparkpost.com/api/metrics This example demonstrates a GET request to the mailbox provider metrics endpoint and its corresponding JSON response. It illustrates how to query metrics like 'count_injected' and 'count_sent' for different mailbox providers. ```http GET /api/v1/metrics/deliverability/mailbox-provider?from=2021-03-02T08:00&limit=5&order_by=count_injected ``` ```json { "results": [ { "count_injected": 109849, "count_targeted": 110923, "count_rejected": 1074, "count_sent": 107610, "mailbox_provider": "Verizon Media Group" }, { "count_injected": 102555, "count_targeted": 103519, "count_rejected": 964, "count_sent": 100301, "mailbox_provider": "Gmail" }, { "count_injected": 53595, "count_targeted": 54102, "count_rejected": 507, "count_sent": 52385, "mailbox_provider": "Hotmail / Outlook" }, { "count_injected": 16808, "count_targeted": 16962, "count_rejected": 154, "count_sent": 16468, "mailbox_provider": "Free.fr" }, { "count_injected": 7511, "count_targeted": 7576, "count_rejected": 65, "count_sent": 7534, "mailbox_provider": "Educational Institution" } ] } ``` -------------------------------- ### Template Response Example Source: https://developers.sparkpost.com/api/templates Example JSON response when retrieving a template, showing its ID, name, content, and tracking options. ```json { "results": { "id": "summer_sale", "name": "Summer Sale!", "description": "", "has_draft": true, "has_published": true, "published": false, "shared_with_subaccounts": false, "last_update_time": "2014-05-22T15:12:59+00:00", "last_use": "2014-06-02T08:15:30+00:00", "options": { "open_tracking": false, "click_tracking": true, "transactional": false }, "content": { "from": { "email": "marketing@bounces.company.example", "name": "Example Company Marketing" }, "subject": "Summer deals for {{name}}", "reply_to": "Summer deals ", "text": "Check out these deals {{name}}!", "html": "Check out these deals {{name}}!", "headers": { "X-Example-Header": "Summer2014" } } } } ``` -------------------------------- ### GET Request for Mailbox Provider Region Metrics Source: https://developers.sparkpost.com/api/metrics This example demonstrates how to request deliverability metrics, aggregated by mailbox provider region. It specifies a time range, a limit for results, and an ordering parameter. ```bash GET /api/v1/metrics/deliverability/mailbox-provider-region?from=2021-03-02T08:00&limit=5&order_by=count_injected ``` -------------------------------- ### Metrics Deliverability Example (Basic Auth) Source: https://developers.sparkpost.com/api Example of how to retrieve deliverability metrics using cURL with Basic authentication. ```APIDOC ## GET /api/v1/metrics/deliverability (Basic Auth) ### Description Retrieves deliverability metrics using Basic authentication. ### Method GET ### Endpoint `https://api.sparkpost.com/api/v1/metrics/deliverability` ### Parameters #### Query Parameters - **campaigns** (string) - Required - The campaign(s) to filter metrics by. - **from** (string) - Required - The start of the time range for metrics (ISO 8601 format). - **metrics** (string) - Required - A comma-separated list of metrics to retrieve (e.g., `count_targeted,count_sent,count_accepted`). - **timezone** (string) - Optional - The timezone for the time range. - **to** (string) - Required - The end of the time range for metrics (ISO 8601 format). ### Request Example ```curl curl -v \ -H "Content-Type: application/json" \ -u 14ac5499cfdd2bb2859e4476d2e5b1d2bad079bf: \ -X GET "https://api.sparkpost.com/api/v1/metrics/deliverability?campaigns=testjob&from=2022-02-01T14:00&metrics=count_targeted,count_sent,count_accepted&timezone=America%2FNew_York&to=2022-02-02T15:50" ``` ### Response #### Success Response (200) - **results** (object) - Contains the requested metrics. #### Response Example ```json { "results": { "campaigns": [ { "campaign_id": "testjob", "metrics": { "count_targeted": 1000, "count_sent": 950, "count_accepted": 900 } } ] } } ``` ``` -------------------------------- ### Tracking Domain Object Example Source: https://developers.sparkpost.com/api/tracking-domains An example of the structure for a tracking domain object, including its properties and status. ```json { "domain": "example.domain.com", "port": 443, "secure": true, "default": false, "uses_managed_certificate": true, "status": { "verified": false, "cname_status": "pending", "compliance_status": "pending" }, "tls_certificate": { "issued_at": "2026-01-27T19:09:17.000Z", "expires_at": "2026-04-27T19:09:16.000Z", "error_code": null } } ``` -------------------------------- ### Rejection Reason Metrics Request Source: https://developers.sparkpost.com/api/metrics Example GET request for rejection reason metrics, including domain-specific data. Specify a date range and limit. ```http GET /api/v1/metrics/deliverability/rejection-reason/domain?from=2018-07-11T08:00&limit=5 ``` -------------------------------- ### Metrics Deliverability Example Source: https://developers.sparkpost.com/api Example of how to retrieve deliverability metrics using cURL with API key authentication. ```APIDOC ## GET /api/v1/metrics/deliverability ### Description Retrieves deliverability metrics for specified campaigns and time ranges. ### Method GET ### Endpoint `https://api.sparkpost.com/api/v1/metrics/deliverability` ### Parameters #### Query Parameters - **campaigns** (string) - Required - The campaign(s) to filter metrics by. - **from** (string) - Required - The start of the time range for metrics (ISO 8601 format). - **metrics** (string) - Required - A comma-separated list of metrics to retrieve (e.g., `count_targeted,count_sent,count_accepted`). - **timezone** (string) - Optional - The timezone for the time range. - **to** (string) - Required - The end of the time range for metrics (ISO 8601 format). ### Request Example ```curl curl -v \ -H "Content-Type: application/json" \ -H "Authorization: 14ac5499cfdd2bb2859e4476d2e5b1d2bad079bf" \ -X GET "https://api.sparkpost.com/api/v1/metrics/deliverability?campaigns=testjob&from=2022-02-01T14:00&metrics=count_targeted,count_sent,count_accepted&timezone=America%2FNew_York&to=2022-02-02T15:50" ``` ### Response #### Success Response (200) - **results** (object) - Contains the requested metrics. #### Response Example ```json { "results": { "campaigns": [ { "campaign_id": "testjob", "metrics": { "count_targeted": 1000, "count_sent": 950, "count_accepted": 900 } } ] } } ``` ``` -------------------------------- ### Example Seed Config Response Source: https://developers.sparkpost.com/api/inline-seeds An example of a successful response when retrieving seed configuration details. It shows the structure of the returned data. ```json { "results": {} } ``` ```json { "results": { "configs": [ { "threshold": 1000, "duration": 20, "reset": 24, "match": [ "my-campaign", "my-*" ] } ] } } ``` -------------------------------- ### Get Message Events Samples Source: https://developers.sparkpost.com/api/events Returns an example message event for each event type listed in the `events` parameter. If no `events` parameter is provided, it defaults to all event types. ```APIDOC ## GET /api/v1/events/message/samples ### Description Returns an example message event for each event type listed in the `events` parameter. Defaults to all event types. See Events Types for the list of available event types. ### Method GET ### Endpoint /api/v1/events/message/samples ### Parameters #### Query Parameters - **events** (string) - Required/Optional - Event types for which to get a sample payload. Defaults to all event types. See Events Types for the list of available event types. ### Response #### Success Response (200) - **results** (array) - An array of sample event payloads. - **type** (string) - The type of the event. ### Response Example ```json { "results": [ { "type": "bounce", ... } ] } ``` ``` -------------------------------- ### Webhook Events Documentation Response Example Source: https://developers.sparkpost.com/api/webhooks An example of the response structure when requesting documentation for webhook events. It outlines the keys for different event types. ```json { "results": { "message_event": { ... }, "track_event": { ... }, ... } } ``` -------------------------------- ### Sending Domain Response Example Source: https://developers.sparkpost.com/api/sending-domains Example JSON response when listing sending domains, showing domain details and verification statuses. ```JSON { "results": [ { "domain": "example1.com", "tracking_domain": "click.example1.com", "status": { "ownership_verified": true, "spf_status": "unverified", "abuse_at_status": "unverified", "dkim_status": "valid", "cname_status": "valid", "mx_status": "unverified", "compliance_status": "valid", "postmaster_at_status": "unverified", "verification_mailbox_status": "valid", "verification_mailbox": "susan.calvin" }, "shared_with_subaccounts": false, "is_default_bounce_domain" : false }, { "domain": "example2.com", "status": { "ownership_verified": true, "spf_status": "unverified", "abuse_at_status": "unverified", "dkim_status": "valid", "cname_status": "valid", "mx_status": "unverified", "compliance_status": "valid", "postmaster_at_status": "unverified", "verification_mailbox_status": "unverified" }, "shared_with_subaccounts": false, "is_default_bounce_domain" : false } ] } ``` -------------------------------- ### GET /api/v1/ingest/events/samples Source: https://developers.sparkpost.com/api/events-ingest Returns an example message event for each event type listed in the `events` parameter. If no event types are specified, it defaults to returning samples for all available event types. ```APIDOC ## GET /api/v1/ingest/events/samples ### Description Returns an example message event for each event type listed in the `events` parameter. Defaults to all event types. See Events Types for the list of available event types. ### Method GET ### Endpoint /api/v1/ingest/events/samples ### Parameters #### Query Parameters - **events** (string) - Required - Event types for which to get a sample payload. Defaults to all event types. See Events Types for the list of available event types. ### Response #### Success Response (200) - **results** (array) - An array of sample event payloads. - **type** (string) - The type of the event. #### Response Example ```json { "results": [ { "type": "delivery", ... } ] } ``` ``` -------------------------------- ### Example Response for Listing IP Pools Source: https://developers.sparkpost.com/api/ip-pools This is an example of the JSON response when listing all IP Pools. It includes details for each pool, such as its ID, name, associated IPs, and domain configurations. ```json { "results": [ { "id": "marketing_ip_pool", "name": "Marketing IP Pool", "ips": [], "signing_domain": "example.com", "fbl_signing_domain": "sparkpostmail.com", "auto_warmup_overflow_pool": "overflow_pool" }, { "id": "default", "name": "Default", "ips": [ { "external_ip": "54.244.54.135", "hostname": "mta472a.sparkpostmail.com", "auto_warmup_enabled": true, "auto_warmup_stage": 5 } ] } ] } ``` -------------------------------- ### List Active Campaigns Request Source: https://developers.sparkpost.com/api/inline-seeds Example GET request to list active seed-eligible campaigns. The X-MSYS-SUBACCOUNT header can be used to filter by subaccount. ```bash GET /api/v1/inline-seeds/status?id=my_campaign&sending_domain=foo.example.com ``` -------------------------------- ### cURL Request with Basic Authentication Source: https://developers.sparkpost.com/api/index Example of making a GET request to the metrics endpoint using cURL with Basic authentication via the -u flag. ```bash curl -v \ -H "Content-Type: application/json" \ -u 14ac5499cfdd2bb2859e4476d2e5b1d2bad079bf: \ -X GET "https://api.sparkpost.com/api/v1/metrics/deliverability?campaigns=testjob&from=2022-02-01T14:00&metrics=count_targeted,count_sent,count_accepted&timezone=America%2FNew_York&to=2022-02-02T15:50" ``` -------------------------------- ### cURL Request with API Key Authentication Source: https://developers.sparkpost.com/api/index Example of making a GET request to the metrics endpoint using cURL with API key authentication. Ensure resource URIs with multiple query parameters are quoted. ```bash curl -v \ -H "Content-Type: application/json" \ -H "Authorization: 14ac5499cfdd2bb2859e4476d2e5b1d2bad079bf" \ -X GET "https://api.sparkpost.com/api/v1/metrics/deliverability?campaigns=testjob&from=2022-02-01T14:00&metrics=count_targeted,count_sent,count_accepted&timezone=America%2FNew_York&to=2022-02-02T15:50" ``` -------------------------------- ### Complex Dynamic Content Example with AMP HTML in Loop Source: https://developers.sparkpost.com/api/template-language This example demonstrates a complex scenario using dynamic content within an `each` loop for both HTML and AMP HTML parts of an email, including substitution data for names and offers. ```json { "name": "John", "offers": [ "offer1", "offer3" ], "dynamic_html": { "offer1": "Premium-brand wirecutters", "offer2": "Corks", "offer3": "Super-effective bug spray" }, "dynamic_amp_html": { "offer1": "Premium-brand wirecutters", "offer2": "Corks", "offer3": "Super-effective bug spray" }, "content": { "html": "

Today's special offers

", "amp_html": "

Today's special offers

", "from": "test@example.com", "subject": "offers" } } ``` -------------------------------- ### Get Inline Seeds Options Request Source: https://developers.sparkpost.com/api/inline-seeds Example PUT request to update inline seeding options. The request body specifies the desired 'enabled' state. ```bash PUT /api/v1/inline-seeds/options ``` -------------------------------- ### Rejection Reason Metrics Response Example Source: https://developers.sparkpost.com/api/metrics Example JSON response for rejection reason metrics, showing counts of delayed messages per reason. ```json { "results": [ { "reason": "400 fake tempfail reason", "count_delayed": 200, "count_delayed_first": 100 }, { "reason": "425 fake tempfail reason", "count_delayed": 100, "count_delayed_first": 50 } ] } ``` -------------------------------- ### Example Response for Message Events Source: https://developers.sparkpost.com/api/events This is an example of a successful response when searching for message events, showing details of a specific error event. ```json { "results": [ { "retryable": false, "number_succeeded": 440, "event_id": "1d1941e9-4987-1a6c-b124-2a4328585721", "number_failed": 460, "batch_id": "fbd59e4c-1629-4736-803d-201ff9fa8dd6", "expiration_timestamp": "2019-06-16T19:02:09.373Z", "error_type": "validation", "href": "https://api.sparkpost.com/ingest/number_failed/fbd59e4c-1629-4736-803d-201ff9fa8dd6", "type": "error", "customer_id": 8675308, "subaccount_id": 38, "number_duplicates": 20, "timestamp": "2019-06-06T19:02:09.373Z" } ], "total_count": 1, "links": {} } ``` -------------------------------- ### Bounce Reason Metrics Response Example Source: https://developers.sparkpost.com/api/metrics Example JSON response for bounce reason metrics, showing counts for inband and out-of-band bounces per reason and domain. ```json { "results": [ { "reason": "Some Fake Reason", "domain": "example.com", "bounce_class_name": "Undetermined", "bounce_class_description": "The response text could not be identified", "bounce_category_id": 0, "bounce_category_name": "Undetermined", "classification_id": 1, "count_inband_bounce": 119, "count_outofband_bounce": 118, "count_bounce": 237 }, { "reason": "Some Fake Reason", "domain": "aol.com", "bounce_class_name": "Invalid Recipient", "bounce_class_description": "The recipient is invalid", "bounce_category_id": 1, "bounce_category_name": "Hard", "classification_id": 10, "count_inband_bounce": 133, "count_outofband_bounce": 126, "count_bounce": 259 } ] } ``` -------------------------------- ### Usage Response Example Source: https://developers.sparkpost.com/api/usage This is an example of a successful 200 response for the Usage API, detailing recipient validation and messaging metrics for the day and month. ```json { "results": { "recipient_validation": { "day": { "start": "2021-08-03T14:45:00.000Z", "end": "2021-08-04T14:45:00.000Z", "limit": 5000000, "used": 2 }, "month": { "start": "2021-07-09T00:00:00.000Z", "end": "2021-08-09T00:00:00.000Z", "used": 2 }, "last_usage_date": "2020-08-19", "timestamp": "2021-08-04T14:50:53.030Z" }, "messaging": { "day": { "start": "2021-08-03T14:45:00.000Z", "end": "2021-08-04T14:45:00.000Z", "used": 0 }, "month": { "start": "2021-08-04T00:00:00.000Z", "end": "2021-09-04T00:00:00.000Z", "used": 0 }, "last_usage_date": null, "timestamp": "2021-08-04T14:50:54.331Z" } } } ``` -------------------------------- ### Example Response for Listing Recipient Lists Source: https://developers.sparkpost.com/api/recipient-lists This is an example of the JSON response when listing recipient lists. It includes IDs, names, descriptions, and attributes for each list. ```json { "results": [ { "id": "unique_id_4_graduate_students_list", "name": "graduate_students", "description": "An email list of graduate students at UMBC", "attributes": { "internal_id": 112, "list_group_id": 12321 }, "total_accepted_recipients": 3 }, { "id": "unique_id_4_undergraduates", "name": "undergraduate_students", "description": "An email list of undergraduate students at UMBC", "attributes": { "internal_id": 111, "list_group_id": 11321 }, "total_accepted_recipients": 8 } ] } ``` -------------------------------- ### Seed Status Response Example Source: https://developers.sparkpost.com/api/inline-seeds An example of a successful response when retrieving seed status. It details campaign information, sending domains, counts, and seeding thresholds. ```json { "results": [ { "campaign": "my_campaign", "sending_domain": "foo.example.com", "count": 1256, "threshold": 1256, "seed_start": 1620078946682, "duration": 30 }, { "campaign": "second_campaign", "sending_domain": "bar.example.com", "count": 1337, "threshold": 5000, "seed_start": null, "duration": 30, "subaccount_id": 123 } ] } ``` -------------------------------- ### Delay Reason Metrics Response Example Source: https://developers.sparkpost.com/api/metrics Example JSON response for delay reason metrics, including the domain, reason, and counts of delayed messages. ```json { "results": [ { "reason": "400 fake tempfail reason", "domain": "example.com", "count_delayed": 200, "count_delayed_first": 100 }, { "reason": "425 fake tempfail reason", "domain": "aol.com", "count_delayed": 100, "count_delayed_first": 50 } ] } ``` -------------------------------- ### Sample Webhook Event Payload Response Example Source: https://developers.sparkpost.com/api/webhooks An example of the response structure when requesting a sample payload for a specific webhook event. Note that the actual data sent to your URL will not include the top-level 'results' key. ```json { "results": [ { "msys": { "message_event": { ... } } } ] } ``` -------------------------------- ### Cancel an A/B Test (POST Method Example) Source: https://developers.sparkpost.com/api/ab-testing This example shows how to cancel an A/B test using the POST method. Note that the DELETE method is generally preferred for cancellation operations. ```shell POST /api/v1/ab-test/password-reset/cancel ``` -------------------------------- ### Successful Webhook Creation Response Source: https://developers.sparkpost.com/api/webhooks Example of a successful response when a webhook is created. ```json { "results": { "id": "12affc24-f183-11e3-9234-3c15c2c818c2", "links": [ { "href": "/api/v1/webhooks/12affc24-f183-11e3-9234-3c15c2c818c2", "rel": "urn.msys.webhooks.webhook", "method": [ "GET", "PUT" ] } ] } } ``` -------------------------------- ### Validate Relay Webhook Request Source: https://developers.sparkpost.com/api/relay-webhooks Example of a GET request to validate a relay webhook. ```http GET /api/v1/relay-webhooks/12013026328707075 ``` -------------------------------- ### Example of a link wrapped with a custom tracking domain Source: https://developers.sparkpost.com/api/tracking-domains Demonstrates how a link is wrapped using a custom tracking domain (`click.heml.io`). ```html Build responsive emails ``` -------------------------------- ### GET Request for Deliverability Time-Series Metrics Source: https://developers.sparkpost.com/api/metrics Example of a GET request to retrieve time-series deliverability metrics. Specify parameters like time range, domains, campaigns, IP pools, precision, and timezone. ```http GET /api/v1/metrics/deliverability/time-series?from=2020-10-04T00:00&domains=gmail.com&campaigns=summerSale&ip_pools=ip-pool-1&precision=day&timezone=America/New_York ``` -------------------------------- ### Example of a standard HTML link Source: https://developers.sparkpost.com/api/tracking-domains Illustrates a basic HTML anchor tag before tracking domain wrapping. ```html Build responsive emails ``` -------------------------------- ### Retrieve Query Filters Schema Source: https://developers.sparkpost.com/api/metrics Example GET request to retrieve the JSON schema for advanced filters. ```http GET /api/v1/metrics/deliverability/query-filters-schema ``` -------------------------------- ### GET Request for Watched Domain Metrics Source: https://developers.sparkpost.com/api/metrics This snippet shows an example GET request to the API endpoint for retrieving deliverability metrics by watched domain. It includes parameters for setting the time range, limit, and ordering. ```http GET /api/v1/metrics/deliverability/watched-domain{?from,to,delimiter,domains,campaigns,templates,sending_ips,ip_pools,sending_domains,subaccounts,precision,metrics,timezone,limit,order_by} ``` -------------------------------- ### Example of a link wrapped with default tracking domain Source: https://developers.sparkpost.com/api/tracking-domains Shows how a link is automatically wrapped using SparkPost's default tracking domain (`spgo.io`). ```html Build responsive emails ``` -------------------------------- ### Bounce Classification Metrics Request Source: https://developers.sparkpost.com/api/metrics Example GET request for bounce classification metrics. Specify a date range and desired metrics. ```http GET /api/v1/metrics/deliverability/rejection-reason?from=2018-07-11T08:00&limit=5 ``` -------------------------------- ### Send Email with Go Source: https://developers.sparkpost.com/ This Go program sends an email using the `gosparkpost` library. Initialize the client with your API key and construct a `Transmission` object. Sandbox mode is enabled. ```go package main import ( sp "github.com/SparkPost/gosparkpost" "log" ) func main() { var sparky sp.Client err := sparky.Init(&sp.Config{ApiKey: ""}) if err != nil { log.Fatalf("SparkPost client init failed: %s\n", err) } tx := &sp.Transmission{ Recipients: []string{"developers+go@sparkpost.com"}, Options: &sp.TxOptions{Sandbox: true}, Content: sp.Content{ HTML: "

Testing SparkPost - the most awesomest email service!

", From: "testing@sparkpostbox.com", Subject: "Oh hey", }, } id, _, err := sparky.Send(tx) if err != nil { log.Fatal(err) } log.Printf("Transmission sent with id [%s]\n", id) } ``` -------------------------------- ### Recipient Validation API Request Example Source: https://developers.sparkpost.com/api/recipient-validation This shows the GET request format for validating a single email address using the Recipient Validation API. ```http GET /api/v1/recipient-validation/single/some@ddress.com ``` -------------------------------- ### Create a Webhook Source: https://developers.sparkpost.com/api/webhooks Creates a new webhook. A test POST request is sent to the target URL upon creation. The webhook will start receiving event data after 1 minute if successful. ```APIDOC ## POST /api/v1/webhooks ### Description Creates a new webhook. A test POST request is sent to the target URL upon creation. The webhook will start receiving event data after 1 minute if successful. ### Method POST ### Endpoint /api/v1/webhooks ### Parameters #### Request Body - **name** (string) - required - Name for webhook - **target** (string) - required - URL of the target to which to POST event batches. Only ports 80 for http and 443 for https can be set. - **events** (array) - required - Array of event types this webhook will send. Use the Events Documentation endpoint to list the available event types. - **active** (boolean) - optional - The status of the webhook. When false, the target will no longer receive batches. Defaults to `true`. - **custom_headers** (object) - optional - Object of custom headers to be used during POST requests to target. - **exception_subaccounts** (array) - optional - Array of subaccount numbers to prevent receiving events in your webhook (only available for webhooks with Primary and All Subaccounts event source). Must not have duplicate values nor be empty. Integer values only. Max size: 10. - **auth_type** (enum) - optional - Type of authentication to be used during POST requests to target. Possible Values: `none`, `basic`, `oauth2`. Defaults to `none`. - **auth_request_details** (object) - optional - Object containing details needed to request authorization token for OAuth 2.0. This is required when `auth_type` is oauth2. - **auth_credentials** (object) - optional - Object containing credentials needed to make authorized POST requests for Basic Authentication. This is required when `auth_type` is basic. When `auth_type` is oauth2, it is generated from `auth_request_details`. ### Request Example ```json { "name": "My Webhook", "target": "http://example.com/webhook", "events": ["delivery", "bounce"], "active": true, "auth_type": "basic", "auth_credentials": { "username": "user", "password": "pass" } } ``` ### Response #### Success Response (200) - **results** (object) - Contains confirmation and response details from the test POST request. - **msg** (string) - Confirmation message. - **response** (object) - Details of the test POST request response. - **status** (integer) - HTTP status code of the response. - **headers** (object) - Headers of the response. - **body** (string) - Body of the response. #### Response Example ```json { "results": { "msg": "Test POST to endpoint succeeded", "response": { "status": 200, "headers": { "Content-Type": "text/plain" }, "body": "OK" } } } ``` ``` -------------------------------- ### Inbound Domain Object Example Source: https://developers.sparkpost.com/api/inbound-domains This is an example of the JSON object representing an inbound domain. ```json { "domain": "indbound.example.com" } ``` -------------------------------- ### Create a Webhook Request Source: https://developers.sparkpost.com/api/webhooks This snippet shows a sample POST request to create a webhook. Ensure the target URL is accessible and uses standard ports (80 for HTTP, 443 for HTTPS). ```bash POST /api/v1/webhooks/ { "name": "My Webhook", "target": "http://client.example.com/example-webhook", "events": [ "delivery", "injection", "open", "click" ], "active": true, "auth_type": "none" } ``` -------------------------------- ### Subaccount Pagination Example Source: https://developers.sparkpost.com/api/subaccounts This JSON structure demonstrates a paginated response for subaccounts, including results, total count, and a link to the next page. ```json { "results": [ { "id": 1, "name": "Joe's Garage", "status": "active", "ip_pool": "my_ip_pool", "compliance_status": "active", "options": { "deliverability": true } }, { "id": 2, "name": "SharkPost", "status": "active", "compliance_status": "active", "options": { "deliverability": true } }, { "id": 3, "name": "Dev Avocado", "status": "suspended", "compliance_status": "active", "options": { "deliverability": true } } ], "total_count": 350, "links": { "next": "/api/v1/subaccounts?cursor=WzIxMCwyMTBd&per_page=3&sort_by=id" } } ``` -------------------------------- ### Get Message Event Samples Source: https://developers.sparkpost.com/api/events Obtain sample message event payloads for specified event types. Defaults to all available event types if none are provided. ```bash GET /api/v1/events/message/samples?events=bounce ``` -------------------------------- ### Retrieve Subaccount Summary Source: https://developers.sparkpost.com/api/subaccounts Get the total count of all subaccounts. This is a simple GET request to the summary endpoint. ```http GET /api/v1/subaccounts/summary ``` -------------------------------- ### Recipient Substitution Data Example 1 Source: https://developers.sparkpost.com/api/template-language Example substitution data for a recipient, specifying which banner snippet to render. ```json { "banner_id" : "banner_snippet_A" } ``` -------------------------------- ### Example Error Response Source: https://developers.sparkpost.com/api/index An example of the JSON structure returned for API errors, including message, description, and code. ```APIDOC ## Example Error Response ```json { "errors": [ { "message": "required field is missing", "description": "content object or template_id required", "code": "1400" } ] } ``` ``` -------------------------------- ### Delete a DKIM Key Request Example Source: https://developers.sparkpost.com/api/sending-domains Example of a POST request to delete a DKIM key. Note: The default key cannot be deleted. ```http POST /api/v1/sending-domains/example.com/dkim-keys/marketing/verify ``` ```json {} ``` -------------------------------- ### Request Body for Creating Seed Config Source: https://developers.sparkpost.com/api/inline-seeds Example JSON payload for creating a seed configuration, including threshold, duration, reset time, and a match rule. ```json { "threshold": 1000, "duration": 20, "reset": 24, "match": [ "my-*" ] } ``` -------------------------------- ### Recipient Substitution Data Example 2 Source: https://developers.sparkpost.com/api/template-language Example substitution data for another recipient, specifying a different banner snippet to render. ```json { "banner_id" : "banner_snippet_B" } ``` -------------------------------- ### Event Samples Source: https://developers.sparkpost.com/api/webhooks Returns an example of the event data that will be posted by a webhook for the specified events. The data that will arrive at your target URL during normal operation will not contain the top level `results` key. ```APIDOC ## GET /api/v1/webhooks/events/samples ### Description Returns an example of the event data that will be posted by a webhook for the specified events. The data that will arrive at your target URL during normal operation (as opposed to calls to this endpoint) will **not** contain the top level `results` key shown in the example response. ### Method GET ### Endpoint /api/v1/webhooks/events/samples #### Query Parameters - **events** (string) - Required/Optional - Event types for which to get a sample payload, use the Events Documentation endpoint to list the available event types, defaults to all event types. ### Response #### Success Response (200) - **results** (array) - An array of event objects, each containing event data. ### Response Example { "results": [ { "msys": { "message_event": { ... } } } ] } ``` -------------------------------- ### Send Email with Node.js Source: https://developers.sparkpost.com/ This Node.js example demonstrates sending an email using the SparkPost SDK. Initialize the client with your API key and call the `transmissions.send` method. The sandbox mode is enabled. ```javascript const SparkPost = require('sparkpost'); const sparky = new SparkPost(''); sparky.transmissions.send({ options: { sandbox: true }, content: { from: 'testing@sparkpostbox.com', subject: 'Oh hey', html:'

Testing SparkPost - the most awesomest email service!

' }, recipients: [ { address: 'developers+nodejs@sparkpost.com' } ] }) .then(data => { console.log('Woohoo! You just sent your first mailing!'); }) .catch(err => { console.log('Whoops! Something went wrong'); }); ``` -------------------------------- ### Create DKIM Keys (User-provided) Source: https://developers.sparkpost.com/api/sending-domains Creates a new DKIM key using user-provided private key, public key, and selector. All three fields must be specified together. ```bash POST /api/v1/sending-domains/example.com/dkim-keys ``` ```json { "id": "marketing", "private": "MIICXQIBAAJBALxYLMK...", "public": "MFwwDQYJKoZIhvcNAQEB...", "selector": "mkt2025" } ``` -------------------------------- ### Bounce Classification Metrics Response Example Source: https://developers.sparkpost.com/api/metrics Example JSON response for bounce classification metrics, showing counts for different bounce categories. ```json { "results": [ { "bounce_class_name": "Undetermined", "bounce_class_description": "The response text could not be identified", "bounce_category_name": "Undetermined", "count_bounce": 226, "count_inband_bounce": 205, "count_outofband_bounce": 21, "classification_id": 1 }, { "bounce_class_name": "Invalid Recipient", "bounce_class_description": "The recipient is invalid", "bounce_category_name": "Hard", "count_bounce": 249, "count_inband_bounce": 224, "count_outofband_bounce": 25, "classification_id": 10 } ] } ``` -------------------------------- ### Send Transmission Request Example Source: https://developers.sparkpost.com/api/transmissions A sample request body for sending a transmission with specified content and recipients. This example uses a template ID. ```json { "content": { "template_id": "black_friday", "use_draft_template": true }, "substitution_data": { "discount": "25%" }, "recipients": [ { "address": { "email": "wilma@flintstone.com", "name": "Wilma Flintstone" }, "substitution_data": { "first_name": "Wilma", "last_name": "Flintstone" } } ] } ``` -------------------------------- ### Compare Group Example with AND Operator Source: https://developers.sparkpost.com/api/metrics Illustrates a compare group using the 'AND' operator with multiple filter conditions on 'domains' and 'sending_domains'. ```json { "AND":{ "domains":{ "eq":[ "gmail.com", "yahoo.com", "hotmail.com" ], "like":[ "mail" ] }, "sending_domains":{ "notEq": [ "sparkpost.com" ], "notLike": [ ".io" ] } } } ``` -------------------------------- ### Send Email with Elixir Source: https://developers.sparkpost.com/ An Elixir example demonstrating how to send an email using the SparkPost library. It defines a `Transmission` with inline content and sandbox options enabled. ```elixir alias SparkPost.{Content, Transmission} defmodule MyApp do def main(args) do Transmission.send(%Transmission{ recipients: ["developers+elixir@sparkpost.com"], content: %Content.Inline{ from: "testing@sparkpostbox.com", subject: "Oh hey", html: "

Testing SparkPost - the most awesomest email service!

", }, options: %Transmission.Options{sandbox: true} }) end end ```