Last modified: Aug 12, 2024

Send email notifications

Endpoint for sending an email notification to one or more recipient.

Endpoint

POST /orders/email

Authentication

This API requires authentication and the request must also include one of the following:

  • Maskinporten scope altinn:serviceowner/notifications.create (for external system callers)
  • Platform Access Token (for Altinn Apps and internal Altinn systems)

See Authentication and Authorization for more information.

Request

Content-type

application/json

Request body

The request body must contain the order request formatted as an EmailNotificationOrderRequestExt and serialized as JSON.

Required order request properties

body

Type: string

The body of the email in either plain text or HTML format.

subject

Type: string

The subject of the subject of the email.

recipients

Type: List of RecipientExt

A list containing one or more recipient objects, each recipient containing either an email address, a national identity number or an organization number.

Optional order request properties

contentType

Type: enum EmailContentTypeExt

Default: Plain

The content type of the email can be either Plain or Html.

requestedSendTime

Type: DateTime

Default: Current time

The date and time (with time zone specification) when the notification should be sent to recipient.

sendersReference

Type: string

An internal reference for notification creator to lookup or identify the notification in the future. Could be a case number or another id. It is recommended, but not required, that the sender’s reference is unique within the organization’s notification orders.

resourceId

Type: string

The ID of the Altinn resource the notifications should be related to as the ID appears in the Altinn Resource Registry. For an Altinn app with ID {org}/{app} the format of the resourceId is app_{org}_{app} e.g. app_ttd_apps-test.

ignoreReservation

Type: boolan

A boolean indicating wether the notification content satisfies the requirements for overriding KRR reservations when sending notifications to an individual.

conditionEndpoint

Type: Url

The URL to use when checking whether the condition to send the notification is met.

Response

Response codes

  • 202 Accepted: The request was accepted and a notification order has been successfully generated.
  • 400 Bad Request: The request was invalid. Refer to problem details in response body for further information.
  • 401 Unauthorized: Indicates a missing, invalid or expired authorization header.
  • 403 Forbidden: Indicates missing or invalid scope or Platform Access Token.

Content-Type

  • application/json

Response body

The response body is formatted as an NotificationOrderRequestResponseExt.cs and serialized as JSON.

Find a short description of each property below.

orderId

Type: GUID

The generated ID for the notification order.

recipientLookup*

Type: RecipientLookupResultExt

The result object describing the result of the recipient lookup containing the properties below.

  • status: the result of the initial lookup
  • isReserved: a list containing national identity numbers for recipients that are reserved
  • missingContact: a list containing national identity numbers and organization numbers for recipients where contact details for selected notification channel were not identified
StatusDescription
SuccessThe recipient lookup was successful for all recipients.
PartialSuccessThe recipient lookup was successful for some recipients.
FailedThe recipient lookup failed for all recipients.

* Property is only included if order request requires recipient lookup

Response headers

Location

Type: URL

The self link for the generated notification order

Examples

Request

In the example we have included place holders for both the Platform Access and Altinn token.

You only need one of them, reference the Authentication section for which one applies to your use case.

curl --location 'https://platform.altinn.no/notifications/api/v1/orders/email' \
--header 'Content-Type: application/json' \
--header 'PlatformAccessToken: [INSERT PLATFORM ACCESS TOKEN]' \
--header 'Authorization: Bearer [INSERT ALTINN TOKEN]' \
--data-raw '{
    "sendersReference": "ref-2023-12-01",
	"subject": "A test email from Altinn Notifications",
	"body": "A message to be sent immediately from an org.",
	"contentType": "Plain",
    "recipients":[
        {"emailAddress":"testuser@altinn.no"},
        {"nationalIdentityNumber":"11876995923"},
        {"organizationNumber":"311000179"}]

}'

Response

202 Accepted

In cases where reservation check or address lookup of recipients is required for an order, the initial result of the lookup will be included in the response. This includes a list containing national identity number for all reserved persons and a list containing national identity number or organization number for the recipients we could not find contact details for.

Headers:

-- header 'Location: https://platform.altinn.no/notifications/api/v1/orders/f1a1cc30-197f-4f34-8304-006ce4945fd1'

Body:

{
    "orderId": "f1a1cc30-197f-4f34-8304-006ce4945fd1",
    "recipientLookup": {
        "status": "PartialSuccess",
        "isReserved": ["11876995923"],
        "missingContact": []
    }
}

400 Bad Request

Response contains a problem details object with the error message in the detail property.

{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
    "title": "One or more validation errors occurred.",
    "status": 400,
    "traceId": "00-9ac2962c93d79629aa5c3744e4259663-344b49720aa49b0a-00",
    "errors": {
        "Subject": [
            "'Subject' must not be empty."
        ]
    }
}