Skip to main content

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
ParameterRequiredDescription
subjectYesThe subject of the message
bodyYesThe text content of the message
autoDeleteDateNoThe date the message is automatically deleted. The deletion happens at the end of the given date.
requestSignatureNoIndicates whether to request a signature from the recipients
canReplyNoIndicates whether the recipients can reply to the message
recipientsYesAn array of recipients. Must contain at least one object.
recipients[].ssnYesThe SSN of the recipient
recipients[].countryYesThe country associated with the given SSN: SWEDEN, NORWAY, DENMARK or FINLAND
recipients[].emailNoAn email to send a notification to
recipients[].phoneNoA phone number to send a notification to
agentYesThe agent to indentify as
agent.ssnNoThe SSN of the agent, if the agent is a eID user.
agent.countryNoThe country associated with the given SSN, if any.
agent.usernameNoThe username of the agent, if the agent is a username/password user.
agent.nameIdNoThe 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​

StatusMessageDescription
400Invalid agentThe agent does not match a user in your company.
400Invalid SSNA recipient's ssn is not valid for its country.
400Only one attachment allowedMore than one file was sent in one attachment request.
403SafeMail via API disabledSafeMail through the API is not enabled for your company.
403Country disabled for company, Country disabled for userThe recipient's country is not enabled for the company or agent.
403SafeMail by Email disabled, SafeMail by Phone disabledEmail or SMS notifications are not enabled for your company.
403Insufficient permissionsYour company's SafeMail access does not include sending.
400Signing requires an attachmentrequestSignature was set on a message without an attachment.
404Message not foundThe staged message does not exist, is not yours, or has expired.

See Errors for the status codes common to all endpoints.