If Email API calls such as /registerEmail, /registerEmailUser, /deleteEmail or /setEmailTags are rejected as unauthorized, it is almost always the wrong token type or the wrong header format.
What to check
- Use the Device API token. These endpoints belong to the Device API. The Server API token used for
/createMessagewill not work here. Copy the Device API token from Settings > API Access, and make sure the token has access to the project you are calling. - Authenticate with a header, not the body. The token goes in the
Authorizationrequest header; theauthbody field is not used for these methods. - Format the header exactly as the word
Token, a single space, then the token.
Authorization: Token YOUR_DEVICE_API_TOKEN
What Pushwoosh actually returns
Pushwoosh returns the outcome in the JSON status_code field. For /registerEmail the documented codes are:
- 403 — invalid or restricted Device API token ("Token restrictions forbid this operation"). This is the code you get for an authorization problem; fix the token, do not retry.
- 210 — argument or validation error (blacklisted, invalid or disposable address, platform not enabled on your plan). Do not retry.
- 400 — malformed request or a missing required field. Do not retry.
- 500 — temporary server error. This is the only case worth retrying, with exponential backoff.
If your HTTP client reports a bare 401 with no JSON body, the Authorization header is missing or malformed before it reaches the API.
Example request
curl -X POST "https://YOUR_APP_CODE.api.pushwoosh.com/json/1.3/registerEmail" \
-H "Content-Type: application/json" \
-H "Authorization: Token YOUR_DEVICE_API_TOKEN" \
-d '{
"request": {
"application": "YOUR_APP_CODE",
"email": "test@example.com",
"userId": "test-user-123"
}
}'
The generic host https://api.pushwoosh.com/json/1.3/registerEmail works as well.
Comments
0 comments
Please sign in to leave a comment.