Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/alphagov/notifications-api/llms.txt

Use this file to discover all available pages before exploring further.

These endpoints are used by the admin interface to manage services. All endpoints require admin authentication.

List Services

GET /service Retrieve a list of all services, optionally filtered by user or with detailed statistics.

Query Parameters

ParameterTypeDescription
only_activebooleanFilter to only active services (default: false)
detailedbooleanInclude statistics with each service (default: false)
user_iduuidFilter services by user ID
include_from_test_keybooleanInclude notifications from test keys in statistics (default: true)
start_datedateStart date for statistics (YYYY-MM-DD format)
end_datedateEnd date for statistics (YYYY-MM-DD format)

Response

{
  "data": [
    {
      "id": "service-uuid",
      "name": "My Service",
      "active": true,
      "restricted": false,
      "created_at": "2023-01-01T00:00:00Z",
      "organisation_type": "central",
      "email_branding": "branding-uuid",
      "letter_branding": "letter-branding-uuid"
    }
  ]
}

Get Service by ID

GET /service/{service_id} Retrieve details for a specific service.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Query Parameters

ParameterTypeDescription
detailedbooleanInclude statistics (default: false)
today_onlybooleanOnly include today’s statistics (default: false)

Response

{
  "data": {
    "id": "service-uuid",
    "name": "My Service",
    "active": true,
    "restricted": false,
    "created_at": "2023-01-01T00:00:00Z",
    "organisation_type": "central",
    "permissions": ["email", "sms", "letter"],
    "email_branding": "branding-uuid",
    "letter_branding": "letter-branding-uuid",
    "statistics": {
      "email": {"requested": 100, "delivered": 95, "failed": 5},
      "sms": {"requested": 50, "delivered": 48, "failed": 2}
    }
  }
}

Create Service

POST /service Create a new service.

Request Body

{
  "name": "New Service",
  "user_id": "user-uuid",
  "organisation_type": "central",
  "active": true,
  "restricted": true,
  "permissions": ["email", "sms"]
}

Response

{
  "data": {
    "id": "service-uuid",
    "name": "New Service",
    "active": true,
    "restricted": true,
    "created_at": "2023-01-01T00:00:00Z",
    "organisation_type": "central"
  }
}
Status Code: 201 Created

Update Service

POST /service/{service_id} Update an existing service.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Request Body

{
  "name": "Updated Service Name",
  "restricted": false,
  "email_branding": "branding-uuid",
  "letter_branding": "letter-branding-uuid"
}

Response

{
  "data": {
    "id": "service-uuid",
    "name": "Updated Service Name",
    "restricted": false,
    "email_branding": "branding-uuid"
  }
}

Archive Service

POST /service/{service_id}/archive Archive a service. This makes the service inactive, archives templates, and revokes API keys. This operation cannot be reversed.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Response

Status Code: 204 No Content

Find Services by Name

GET /service/find-services-by-name Search for services by partial name match.

Query Parameters

ParameterTypeDescription
service_namestringPartial service name to search for (required)

Response

{
  "data": [
    {
      "id": "service-uuid",
      "name": "Matching Service",
      "active": true,
      "restricted": false,
      "organisation_name": "Cabinet Office"
    }
  ]
}

Get Service Users

GET /service/{service_id}/users Retrieve all users associated with a service.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Response

{
  "data": [
    {
      "id": "user-uuid",
      "name": "John Smith",
      "email_address": "john.smith@example.gov.uk",
      "mobile_number": "+447700900123",
      "permissions": ["manage_users", "manage_templates", "send_messages"]
    }
  ]
}

Add User to Service

POST /service/{service_id}/users/{user_id} Add a user to a service with specified permissions.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID
user_iduuidThe user ID

Request Body

{
  "permissions": [
    {"permission": "send_messages"},
    {"permission": "manage_templates"}
  ],
  "folder_permissions": ["folder-uuid-1", "folder-uuid-2"]
}

Response

{
  "data": {
    "id": "service-uuid",
    "name": "My Service",
    "users": [
      {
        "id": "user-uuid",
        "name": "John Smith"
      }
    ]
  }
}
Status Code: 201 Created

Remove User from Service

DELETE /service/{service_id}/users/{user_id} Remove a user from a service.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID
user_iduuidThe user ID

Response

Status Code: 204 No Content

Errors

  • 400 Bad Request: Cannot remove the only user from a service
  • 404 Not Found: User not found in service

Get Service History

GET /service/{service_id}/history Retrieve historical changes to a service, including service updates, API key changes, and template modifications.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Response

{
  "data": {
    "service_history": [
      {
        "id": "service-uuid",
        "name": "My Service",
        "version": 2,
        "updated_at": "2023-01-01T00:00:00Z"
      }
    ],
    "api_key_history": [
      {
        "id": "key-uuid",
        "name": "API Key 1",
        "created_at": "2023-01-01T00:00:00Z",
        "revoked_at": null
      }
    ],
    "template_history": [
      {
        "id": "template-uuid",
        "name": "Welcome Email",
        "version": 3,
        "updated_at": "2023-01-01T00:00:00Z"
      }
    ]
  }
}

Get Guest List

GET /service/{service_id}/guest-list Retrieve the guest list for a restricted service. The guest list contains email addresses and phone numbers that can receive notifications in trial mode.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Response

{
  "email_addresses": ["test@example.gov.uk"],
  "phone_numbers": ["+447700900123"]
}

Update Guest List

PUT /service/{service_id}/guest-list Update the guest list for a restricted service.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Request Body

{
  "email_addresses": ["test1@example.gov.uk", "test2@example.gov.uk"],
  "phone_numbers": ["+447700900123", "+447700900456"]
}

Response

Status Code: 204 No Content

Service Statistics

GET /service/{service_id}/statistics Get notification statistics for a service.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Query Parameters

ParameterTypeDescription
today_onlybooleanOnly return today’s statistics (default: false)
limit_daysintegerNumber of days to include (default: 7)

Response

{
  "data": {
    "email": {
      "requested": 1000,
      "delivered": 950,
      "failed": 50
    },
    "sms": {
      "requested": 500,
      "delivered": 490,
      "failed": 10
    },
    "letter": {
      "requested": 100,
      "delivered": 95,
      "failed": 5
    }
  }
}

Get Monthly Notification Stats

GET /service/{service_id}/notifications/monthly Get monthly notification statistics for a financial year.

Path Parameters

ParameterTypeDescription
service_iduuidThe service ID

Query Parameters

ParameterTypeDescription
yearintegerFinancial year (required)

Response

{
  "data": {
    "2023-04": {
      "email": {"requested": 100, "delivered": 95, "failed": 5},
      "sms": {"requested": 50, "delivered": 48, "failed": 2}
    },
    "2023-05": {
      "email": {"requested": 150, "delivered": 140, "failed": 10}
    }
  }
}
See also:

Build docs developers (and LLMs) love