Add project campaign recipients
Required scope: campaigns:manage
Adds up to 1,000 recipients to a campaign that has not started sending. A phone already on the campaign is skipped. Invalid entries are reported and not added.
curl --request POST \
--url https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipients": [
{
"phone": "<string>",
"variables": {}
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({recipients: [{phone: '<string>', variables: {}}]})
};
fetch('https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients"
payload = { "recipients": [
{
"phone": "<string>",
"variables": {}
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients"
payload := strings.NewReader("{\n \"recipients\": [\n {\n \"phone\": \"<string>\",\n \"variables\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}false{
"success": true,
"data": {
"campaignId": "<string>",
"added": 123,
"recipientCount": 123,
"duplicateCount": 123,
"invalidCount": 123,
"invalidRows": [
{
"row": 2,
"reason": "missing_phone"
}
]
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_parameter",
"message": "Correct the invalid request field.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-parameter"
}{
"error": {
"type": "authentication_error",
"code": "invalid_credential",
"message": "Supply a valid credential.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-credential"
}{
"error": {
"type": "permission_error",
"code": "permission_denied",
"message": "The credential does not have access to this resource.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#permission-denied"
}{
"error": {
"type": "invalid_request_error",
"code": "resource_not_found",
"message": "The resource is unavailable to this caller.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#resource-not-found"
}{
"error": {
"type": "conflict_error",
"code": "state_conflict",
"message": "The request conflicts with the resource state.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#state-conflict"
}{
"error": {
"type": "api_error",
"code": "internal_error",
"message": "An unexpected service failure occurred. Keep the request ID for support.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#internal-error"
}Authorizations
Polymorfa organization key (pmfa_ prefix), project token (pmfa_pt_ prefix) where supported, or short-lived client token (pmfa_ct_ prefix). Organization and project keys may be personal or service-account owned and enforce selected action scopes. Organization keys cover the team and its projects; project tokens stay inside one project. Client tokens stay inside their live project and session and enforce their client rules.
Path Parameters
Specifies project slug for this path parameter.
Identifier for this resource.
Body
Recipients associated with this native add campaign recipients request.
Value constraints
| Constraint | Accepted input |
|---|---|
| Array size | 1 through 1000 items |
1 - 1000 elementsShow child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"recipients": [
{
"phone": "<string>",
"variables": {}
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({recipients: [{phone: '<string>', variables: {}}]})
};
fetch('https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients"
payload = { "recipients": [
{
"phone": "<string>",
"variables": {}
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.polymorfa.com/messaging/projects/{projectSlug}/campaigns/{id}/recipients"
payload := strings.NewReader("{\n \"recipients\": [\n {\n \"phone\": \"<string>\",\n \"variables\": {}\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}false{
"success": true,
"data": {
"campaignId": "<string>",
"added": 123,
"recipientCount": 123,
"duplicateCount": 123,
"invalidCount": 123,
"invalidRows": [
{
"row": 2,
"reason": "missing_phone"
}
]
}
}{
"error": {
"type": "invalid_request_error",
"code": "invalid_parameter",
"message": "Correct the invalid request field.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-parameter"
}{
"error": {
"type": "authentication_error",
"code": "invalid_credential",
"message": "Supply a valid credential.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#invalid-credential"
}{
"error": {
"type": "permission_error",
"code": "permission_denied",
"message": "The credential does not have access to this resource.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#permission-denied"
}{
"error": {
"type": "invalid_request_error",
"code": "resource_not_found",
"message": "The resource is unavailable to this caller.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#resource-not-found"
}{
"error": {
"type": "conflict_error",
"code": "state_conflict",
"message": "The request conflicts with the resource state.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#state-conflict"
}{
"error": {
"type": "api_error",
"code": "internal_error",
"message": "An unexpected service failure occurred. Keep the request ID for support.",
"param": null,
"request_id": "5f0c2a8e-3b1d-4c6f-9e2a-7d4b1c8f6a30"
},
"data": null,
"docs": "https://docs.polymorfa.com/api/errors#internal-error"
}