:
Last modified: Jan 29, 2024

Send sms notifications

Endpoint for sending an sms to one or more recipient with known contact details.

On this page:

Endpoint

POST /orders/sms

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 SmsNotificationOrderRequestExt and serialized as JSON.

Required order request properties

body

Type: string

The contents of the SMS.

recipients

Type: List of RecipientExt

A list containing one or more recipient objects, each representing a recipient with a mobile number.

Optional order request properties

senderNumber

Type: string

Default: Altinn The string to use as the sender of the SMS.

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 organisation’s notification orders.

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 OrderIdExt.cs and serialized as JSON.

Find a short description of each property below.

orderId

Type: GUID

The generated id for the notification order

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/sms' \
--header 'Content-Type: application/json' \
--header 'PlatformAccessToken: [INSERT PLATFORM ACCESS TOKEN]' \
--header 'Authorization: Bearer [INSERT ALTINN TOKEN]' \
--data-raw '{
    "sendersReference": "ref-2024-01-01",
	"body": "A text message to be sent immediately from an org.",
    "recipients":[{"mobileNumber":"+4799999999"}]
}'

Response

202 Accepted

Response body contains the ID for the cloud event.

{
    "orderId": "f1a1cc30-197f-4f34-8304-006ce4945fd1"
}

Response headers contains a self link for retrieving the generated notification order.

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

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": [
            "'Body' must not be empty."
        ]
    }
}