Retrieve a campaign
/api/v1/campaigns/{campaign}Parameters
| Name | In | Type | Description |
|---|---|---|---|
campaignrequired | path | string | The campaign identifier. |
Request
/api/v1/campaigns/{campaign}curl -X GET 'https://app.mailyte.com/api/v1/campaigns/01JBT8XQ2M9WYC3K4F6R7S8T9V' \
-H 'Authorization: Bearer mk_live_YOUR_API_KEY'const response = await fetch('https://app.mailyte.com/api/v1/campaigns/01JBT8XQ2M9WYC3K4F6R7S8T9V', {
method: 'GET',
headers: {
Authorization: 'Bearer mk_live_YOUR_API_KEY',
},
});
const { data } = await response.json();import requests
response = requests.get(
"https://app.mailyte.com/api/v1/campaigns/01JBT8XQ2M9WYC3K4F6R7S8T9V",
headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
)
data = response.json()["data"]<?php
$response = Http::withToken('mk_live_YOUR_API_KEY')
->get('https://app.mailyte.com/api/v1/campaigns/01JBT8XQ2M9WYC3K4F6R7S8T9V');
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://app.mailyte.com/api/v1/campaigns/01JBT8XQ2M9WYC3K4F6R7S8T9V")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer mk_live_YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Success.
dataobjectThe field SET never varies between a list and a single campaign. Two values do:
content.html/content.textandaudience.excluded_contact_idsare null in a list response. See those fields.objectstringcampaignidstringUnique identifier for the campaign.
namestringstatestringdraft | scheduled | sending | paused | sent | canceled | unknownWhere the campaign is. -
draft: editable, not going anywhere. -scheduled: waiting for its send time. -sending: going out now. -paused: stopped partway and can be resumed. -sent: finished sending. ReadGET /campaigns/{campaign}/statsfor how many were delivered. -canceled: stopped for good, though it can be resent. -unknown: a state we did not recognise. Contact support. To see whether a campaign can go out, usePOST /campaigns/{campaign}/preflight.senderobjectThe sender this campaign sends as. Whether the sender is verified is checked by preflight.
idstringnamestringThe sender's display name.
emailstring
contentobjectsubjectstringThe subject line. Null when none has been written. A campaign with no subject and no template cannot be sent.
template_idstringThe template this campaign uses, if any. When a template is set, it is used instead of the campaign's own
subject,htmlandtext. Null when the campaign uses its own content.has_htmlbooleanALWAYS a real answer, in a list as well as on a single campaign. This is the boolean to test — not
html !== null.has_textbooleanALWAYS a real answer, in a list as well as on a single campaign. This is the boolean to test — not
text !== null.htmlstringThe HTML body. Left out (null) in lists to keep them small:
has_htmlsays whether there is one. Fetch the campaign on its own to read it.textstringThe plain-text body. Left out (null) in lists to keep them small:
has_textsays whether there is one. Fetch the campaign on its own to read it.
audienceobjectStatic lists plus rule-based segments, minus per-campaign exclusions — the union-then-subtract the send path materialises.
listsarray<object>The static lists this campaign sends to, named so you do not have to fetch each one to display it. Null only if the relation was not loaded.
idstringnamestringcontact_countintegerHow many contacts are on the list. This is not the number of recipients: lists and segments can overlap, and exclusions and suppressed addresses are removed when sending.
segmentsarray<object>The segments this campaign sends to. A segment's members are worked out when the campaign sends, so no count is given.
idstringnamestring
includes_unlistedbooleanWhether the campaign also goes to contacts who are on no list. A campaign can target only these.
excludedobjectContacts held back from this campaign only; their list membership is untouched.
countintegerHow many contacts are excluded. Always present, including in a list response, so you can tell "none excluded" from "not told you" without fetching the campaign.
contact_idsarray<string>nullin a LIST response means NOT INCLUDED, never "there are none" — the set is unbounded, which is whycountsits beside it. Fetch the campaign on its own to read the ids.
scheduleobjectscheduled_forstringWhen the campaign will go out. Set only while
stateisscheduled.started_atstringWhen the fan-out began. Null until it does — and that is exactly the cut that makes every count in
/statsand the whole timeline in/reportnull rather than zero.completed_atstringWhen the campaign finished sending. Null until then, and for a canceled campaign. Finished sending is not the same as delivered; read
GET /campaigns/{campaign}/statsfor that.
resent_from_campaign_idstringThe campaign this one was resent from. Null when it is an original.
created_atstringupdated_atstring
Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist. |
403 | The key is valid but may not do this: it lacks the required scope, its IP allowlist does not include you, or this endpoint does not accept API keys. |
404 | No such resource in this organization. |
422 | The request was understood but the values were not acceptable. |
429 | Too many requests, or the organization has spent its sending allowance. `Retry-After` says how long to wait. |
Every status, with what causes it and what to do, is on the error reference.