Sending Messages
Stage a message
The POST /v3/safemail/stage endpoint is used to stage a SafeMail message before sending it.
POST /v3/safemail/stage
Authorization: Basic ${ base64(apiKey + ':' + secretKey) }
Content-Type: application/json
| Parameter | Required | Description |
|---|---|---|
| subject | Yes | The subject of the message |
| body | Yes | The text content of the message |
| autoDeleteDate | No | The date the message is automatically deleted. The deletion happens at the end of the given date. |
| requestSignature | No | Indicates whether to request a signature from the recipients |
| canReply | No | Indicates whether the recipients can reply to the message |
| recipients | Yes | An array of recipients. Must contain at least one object. |
| recipients[].ssn | Yes | The SSN of the recipient |
| recipients[].country | Yes | The country associated with the given SSN: SWEDEN, NORWAY, DENMARK or FINLAND |
| recipients[].email | No | An email to send a notification to |
| recipients[].phone | No | A phone number to send a notification to |
| agent | Yes | The agent to indentify as |
| agent.ssn | No | The SSN of the agent, if the agent is a eID user. |
| agent.country | No | The country associated with the given SSN, if any. |
| agent.username | No | The username of the agent, if the agent is a username/password user. |
| agent.nameId | No | The nameId of the agent, if the agent is a SSO user. |
Response example:
HTTP/2.0 201 Created
{
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12",
"autoDeleteDate": "2022-07-25",
"subject": "Subject",
"body": "Body",
"attachments": ["file.pdf"],
"recipients": [
{
"ssn": "YYYYMMDDXXXX",
"country": "SWEDEN"
}
]
}
Add an attachment to a message
The POST /v3/safemail/stage/{id}/attachment endpoint is used to add attachments to a staged SafeMail message.
POST /v3/safemail/stage/{id}/attachment
Authorization: Basic ${ base64(apiKey + ':' + secretKey) }
Content-Type: multipart/form-data; boundary=boundary
--boundary
Content-Disposition: form-data; name="my-file"; filename="my-file.pdf"
// File content
Only one file can be attached per request. The response is a 200 with no body.
Send a staged message
The POST /v3/safemail/stage/{id}/send endpoint is used to send a staged SafeMail message.
POST /v3/safemail/stage/{id}/send
Authorization: Basic ${ base64(apiKey + ':' + secretKey) }
The response is a 200 with the sent message, in the same format as an outbox message in Fetching Messages.
Errors
| Status | Message | Description |
|---|---|---|
| 400 | Invalid agent | The agent does not match a user in your company. |
| 400 | Invalid SSN | A recipient's ssn is not valid for its country. |
| 400 | Only one attachment allowed | More than one file was sent in one attachment request. |
| 403 | SafeMail via API disabled | SafeMail through the API is not enabled for your company. |
| 403 | Country disabled for company, Country disabled for user | The recipient's country is not enabled for the company or agent. |
| 403 | SafeMail by Email disabled, SafeMail by Phone disabled | Email or SMS notifications are not enabled for your company. |
| 403 | Insufficient permissions | Your company's SafeMail access does not include sending. |
| 400 | Signing requires an attachment | requestSignature was set on a message without an attachment. |
| 404 | Message not found | The staged message does not exist, is not yours, or has expired. |
See Errors for the status codes common to all endpoints.