This version is in beta - expect some breaking changes.
Obligations (MTD) API
Available in Sandbox | Yes |
---|---|
Sandbox base URL | https://test-api.service.hmrc.gov.uk |
Available in Production | Yes |
Production base URL | https://api.service.hmrc.gov.uk |
Overview
This API endpoint allows software packages to:
· retrieve obligations for a user's business income sources
· retrieve the crystallisation obligations for a user's Income Tax account
· retrieve the End of Period Statement obligations for a user's business income sources
Versioning
When an API changes in a way that is backwards-incompatible, we increase the version number of the API. See our reference guide for more on versioning.
Errors
We use standard HTTP status codes to show whether an API request succeeded or not. They are usually in the range:
- 200 to 299 if it succeeded, including code 202 if it was accepted by an API that needs to wait for further action
- 400 to 499 if it failed because of a client error by your application
- 500 to 599 if it failed because of an error on our server
Errors specific to each API are shown in the Endpoints section, under Response. See our reference guide for more on errors.
Single errors will be returned in the following format:
{
"code": "FORMAT_FIELD_NAME",
"message": "The provided FieldName is invalid"
}
Where possible, multiple errors will be returned with INVALID_REQUEST
in the following format:
{
"code": "INVALID_REQUEST",
"message": "Invalid request",
"errors": [
{
"code": "RULE_FIELD_NAME",
"message": "The provided FieldName is not allowed"
},
{
"code": "FORMAT_FIELD_NAME",
"message": "The provided FieldName is invalid"
}
]
}
Changelog
You can find the changelog in the mtd-api GitHub wiki.
Support
- Raise non-technical or platform-related issues with the Software Development Support Team (SDST).
- Raise technical issues on the mtd-api GitHub page.
Testing
You can use the sandbox environment to test this API. You can use the Create Test User API or it's frontend service to create test users.
It may not be possible to test all scenarios in the sandbox. You can test some scenarios by passing the Gov-Test-Scenario header. Documentation for each endpoint includes a Test data section, which explains the scenarios that you can simulate using the Gov-Test-Scenario header.
If you have a specific testing need that is not supported in the sandbox, contact our support team.
Some APIs may be marked [test only]. This means that they are not available for use in production and may change.
Endpoints
/obligations/details/{nino}/income-and-expenditure
This endpoint allows a developer to retrieve obligations for a user's business income sources. The account identifier (National Insurance number) must be provided.
Authorisation
This endpoint is
user-restricted
and requires an Authorization
header containing an OAuth 2.0 Bearer Token with the read:self-assessment
scope.
Path parameters
Name | Description |
---|---|
nino
string
required
|
National Insurance number, in the format AA999999A.
For example: |
Query parameters
Name | Description |
---|---|
typeOfBusiness
string
optional
|
The type of business whose obligations are to be returned, must be one of:
|
businessId
string
optional
|
The unique identifier for the business whose obligations are to be returned. Must conform to the regular expression ^X[a-zA-Z0-9]{1}IS[0-9]{11}$
For example: |
fromDate
string
optional
|
The start date of the range to filter obligations in the format YYYY-MM-DD. Mandatory if the “to” query parameter is supplied. If the “from” and “to” date parameters are not supplied, the date range will default to a year from today unless the status parameter is set to “Open”.
For example: |
toDate
string
optional
|
The end date of the range to filter obligations in the format YYYY-MM-DD. Mandatory if the “from” query parameter is supplied. If the “from” and “to” date parameters are not supplied, the date range will default to a year from today unless the status parameter is set to “Open”.
For example: |
status
string
optional
|
Obligation status to return: Open or Fulfilled only. To retrieve all obligations omit the status.
|
Request headers
Name | Description |
---|---|
Accept
required
|
Specifies the response format and the version of the API to be used. For example: application/vnd.hmrc.1.0+json
|
Gov-Test-Scenario
optional
|
Only in sandbox environment. See Test Data table for all header values. For example: -
|
Authorization
required
|
An
OAuth 2.0 Bearer Token
with the read:self-assessment scope.
For example: Bearer bb7fed3fe10dd235a2ccda3d50fb
|
See also fraud prevention for other request headers which will become mandatory.
Response headers
Name | Description |
---|---|
X-CorrelationId
required
|
Unique ID for operation tracking For example: c75f40a6-a3df-4429-a697-471eeec46435
|
See also fraud prevention for other request headers which will become mandatory.
Response
HTTP status: 200 (OK)
{ "obligations": [ { "typeOfBusiness": "self-employment", "businessId": "XAIS12345678910", "obligationDetails": [ { "periodStartDate": "2019-01-01", "periodEndDate": "2019-03-31", "dueDate": "2019-04-30", "receivedDate": "2019-04-25", "status": "Fulfilled" }, { "periodStartDate": "2019-04-01", "periodEndDate": "2019-06-30", "dueDate": "2019-07-31", "receivedDate": "2019-07-01", "status": "Fulfilled" }, { "periodStartDate": "2019-07-01", "periodEndDate": "2019-9-30", "dueDate": "2019-10-31", "receivedDate": "2019-10-08", "status": "Fulfilled" }, { "periodStartDate": "2019-10-01", "periodEndDate": "2019-12-31", "dueDate": "2020-01-31", "status": "Open" } ] } ] }
Name | Description |
---|---|
obligations
array
required
|
An array to return one or more businesses and their obligations details. |
typeOfBusiness
string
required
|
Identifies the type of business income source. One of "self-employment", "uk-property" or "foreign-property".
For example: |
businessId
string
required
|
The unique identifier for this business income source.
For example: |
obligationDetails
array
required
|
An array holding the obligations for the business income source. |
periodStartDate
string
required
|
The start date of this obligation period in the format YYYY-MM-DD.
For example: |
periodEndDate
string
required
|
The end date of this obligation period in the format YYYY-MM-DD.
For example: |
dueDate
string
required
|
The due date for this obligation period in the format YYYY-MM-DD.
For example: |
status
string
required
|
The status of the obligation, one of: "Open" or "Fulfilled".
For example: |
receivedDate
string
optional
|
The date this obligation period was fulfilled in the format YYYY-MM-DD.
For example: |
Error scenarios
Scenario | HTTP status | Code |
---|---|---|
The format of the supplied NINO field is not valid. |
400 (Bad Request) |
FORMAT_NINO |
The format of the type of business field is not valid. |
400 (Bad Request) |
FORMAT_TYPE_OF_BUSINESS |
The format of the business ID field is not valid. |
400 (Bad Request) |
FORMAT_BUSINESS_ID |
The format of the From date field is not valid. |
400 (Bad Request) |
FORMAT_FROM_DATE |
The format of the To date field is not valid. |
400 (Bad Request) |
FORMAT_TO_DATE |
The format of the status field is not valid. |
400 (Bad Request) |
FORMAT_STATUS |
The From date parameter is missing. |
400 (Bad Request) |
MISSING_FROM_DATE |
The To date parameter is missing. |
400 (Bad Request) |
MISSING_TO_DATE |
The To date is before the From date. |
400 (Bad Request) |
RANGE_TO_DATE_BEFORE_FROM_DATE |
The Type of Business parameter is missing. |
400 (Bad Request) |
MISSING_TYPE_OF_BUSINESS |
The date range is longer than 366 days. |
400 (Bad Request) |
RULE_DATE_RANGE_INVALID |
The From date specified is before 2018-04-06. |
400 (Bad Request) |
RULE_FROM_DATE_NOT_SUPPORTED |
The client or agent is not authorised. This is because: the client is not subscribed to MTD, the agent is not subscribed to Agent Services, or the client has not authorised the agent to act on their behalf. |
403 (Forbidden) |
CLIENT_OR_AGENT_NOT_AUTHORISED |
The matching resource is not found. |
404 (Not Found) |
MATCHING_RESOURCE_NOT_FOUND |
No obligations found using this filter. |
404 (Not Found) |
NO_OBLIGATIONS_FOUND |
For error scenarios that are common across all APIs, and for error formats, see our reference guide.
Test data
Scenario simulations using Gov-Test-Scenario headers is only available in the sandbox environment.
Header Value (Gov-Test-Scenario) | Scenario |
---|---|
N/A - DEFAULT |
Simulate a successful response. |
OPEN |
Simulate a success response with an open obligation. |
FULFILLED |
Simulate a success response with a fulfilled obligation. |
NOT_FOUND |
Simulate a scenario where no data is found. |
/obligations/details/{nino}/crystallisation
This endpoint allows a developer to retrieve the Crystallisation obligations for a user's Income Tax account. The account identifier (National Insurance number) must be provided.
Authorisation
This endpoint is
user-restricted
and requires an Authorization
header containing an OAuth 2.0 Bearer Token with the read:self-assessment
scope.
Path parameters
Name | Description |
---|---|
nino
string
required
|
National Insurance number, in the format AA999999A.
For example: |
Query parameters
Name | Description |
---|---|
taxYear
string
optional
|
The tax year the data applies to. If not supplied it will default to the last completed tax year. The earliest permitted tax year is 2017-18.
|
Request headers
Name | Description |
---|---|
Accept
required
|
Specifies the response format and the version of the API to be used. For example: application/vnd.hmrc.1.0+json
|
Gov-Test-Scenario
optional
|
Only in sandbox environment. See Test Data table for all header values. For example: -
|
Authorization
required
|
An
OAuth 2.0 Bearer Token
with the read:self-assessment scope.
For example: Bearer bb7fed3fe10dd235a2ccda3d50fb
|
See also fraud prevention for other request headers which will become mandatory.
Response headers
Name | Description |
---|---|
X-CorrelationId
required
|
Unique ID for operation tracking For example: c75f40a6-a3df-4429-a697-471eeec46435
|
See also fraud prevention for other request headers which will become mandatory.
Response
HTTP status: 200 (OK)
{ "periodStartDate": "2018-04-06", "periodEndDate": "2019-04-05", "dueDate": "2020-01-31", "status": "Fulfilled", "receivedDate": "2020-01-25" }
Name | Description |
---|---|
periodStartDate
string
required
|
The start date of this obligation period. Date in the format YYYY-MM-DD.
For example: |
periodEndDate
string
required
|
The end date of this obligation period. Date in the format YYYY-MM-DD.
For example: |
dueDate
string
required
|
The due date for this obligation period. Date in the format YYYY-MM-DD.
For example: |
status
string
required
|
The status of the obligation, one of: `Open` or `Fulfilled`.
For example: |
receivedDate
string
optional
|
The date this obligation period was fulfilled. Date in the format YYYY-MM-DD.
For example: |
Error scenarios
Scenario | HTTP status | Code |
---|---|---|
The format of the supplied NINO field is not valid. |
400 (Bad Request) |
FORMAT_NINO |
The format of the supplied tax year field is not valid. |
400 (Bad Request) |
FORMAT_TAX_YEAR |
The specified tax year is not supported. That is, the tax year specified is before the minimum tax year value. |
400 (Bad Request) |
RULE_TAX_YEAR_NOT_SUPPORTED |
The tax year provided is more than one year in length. |
400 (Bad Request) |
RULE_TAX_YEAR_TOO_LONG |
The format of the loss ID is not valid. |
400 (Bad Request) |
FORMAT_LOSS_ID |
The client or agent is not authorised. This is because: the client is not subscribed to MTD, the agent is not subscribed to Agent Services, or the client has not authorised the agent to act on their behalf. |
403 (Forbidden) |
CLIENT_OR_AGENT_NOT_AUTHORISED |
The remote endpoint has indicated that no data can be found for the given loss ID. |
404 (Not Found) |
MATCHING_RESOURCE_NOT_FOUND |
No obligations found using this filter. |
404 (Not Found) |
NO_OBLIGATIONS_FOUND |
For error scenarios that are common across all APIs, and for error formats, see our reference guide.
Test data
Scenario simulations using Gov-Test-Scenario headers is only available in the sandbox environment.
Header Value (Gov-Test-Scenario) | Scenario |
---|---|
N/A - DEFAULT |
Simulate a success response with a fulfilled obligation. |
FULFILLED |
Simulate a success response with a fulfilled obligation. |
OPEN |
Simulate a success response with an open obligation. |
NOT_FOUND |
Simulate a scenario where no data is found. |
/obligations/details/{nino}/end-of-period-statement
This endpoint allows a developer to retrieve the End of Period Statement obligations for a user's business income sources. The account identifier (National Insurance number) must be provided.
Authorisation
This endpoint is
user-restricted
and requires an Authorization
header containing an OAuth 2.0 Bearer Token with the read:self-assessment
scope.
Path parameters
Name | Description |
---|---|
nino
string
required
|
National Insurance number, in the format AA999999A.
For example: |
Query parameters
Name | Description |
---|---|
typeOfBusiness
string
optional
|
The type of business whose obligations are to be returned, must be one of:
|
businessId
string
optional
|
The unique identifier for the business whose obligations are to be returned. Must conform to the regular expression ^X[a-zA-Z0-9]{1}IS[0-9]{11}$
For example: |
fromDate
string
optional
|
The start date of the range to filter obligations in the format YYYY-MM-DD. Mandatory if the “to” query parameter is supplied. If the “from” and “to” date parameters are not supplied, the date range will default to a year from today unless the status parameter is set to “Open”.
For example: |
toDate
string
optional
|
The end date of the range to filter obligations in the format YYYY-MM-DD. Mandatory if the “from” query parameter is supplied. If the “from” and “to” date parameters are not supplied, the date range will default to a year from today unless the status parameter is set to “Open”.
For example: |
status
string
optional
|
Obligation status to return: Open or Fulfilled only. To retrieve all obligations omit the status.
|
Request headers
Name | Description |
---|---|
Accept
required
|
Specifies the response format and the version of the API to be used. For example: application/vnd.hmrc.1.0+json
|
Gov-Test-Scenario
optional
|
Only in sandbox environment. See Test Data table for all header values. For example: -
|
Authorization
required
|
An
OAuth 2.0 Bearer Token
with the read:self-assessment scope.
For example: Bearer bb7fed3fe10dd235a2ccda3d50fb
|
See also fraud prevention for other request headers which will become mandatory.
Response headers
Name | Description |
---|---|
X-CorrelationId
required
|
Unique ID for operation tracking For example: c75f40a6-a3df-4429-a697-471eeec46435
|
See also fraud prevention for other request headers which will become mandatory.
Response
HTTP status: 200 (OK)
{ "obligations": [ { "typeOfBusiness": "self-employment", "businessId": "XAIS12345678910", "obligationDetails": [ { "periodStartDate": "2018-01-01", "periodEndDate": "2018-12-31", "dueDate": "2020-01-31", "receivedDate": "2019-05-13", "status": "Fulfilled" }, { "periodStartDate": "2019-01-01", "periodEndDate": "2019-12-31", "dueDate": "2021-01-31", "status": "Open" } ] } ] }
Name | Description |
---|---|
obligations
array
required
|
An array to return one or more businesses and their obligations details. |
typeOfBusiness
string
required
|
Identifies the type of business income source. One of "self-employment", "uk-property" or "foreign-property".
For example: |
businessId
string
required
|
The unique identifier for this business income source.
For example: |
obligationDetails
array
required
|
An array holding the obligations for the business income source. |
periodStartDate
string
required
|
The start date of this obligation period in the format YYYY-MM-DD.
For example: |
periodEndDate
string
required
|
The end date of this obligation period in the format YYYY-MM-DD.
For example: |
dueDate
string
required
|
The due date for this obligation period in the format YYYY-MM-DD.
For example: |
status
string
required
|
The status of the obligation, one of: "Open" or "Fulfilled".
For example: |
receivedDate
string
optional
|
The date this obligation period was fulfilled in the format YYYY-MM-DD.
For example: |
Error scenarios
Scenario | HTTP status | Code |
---|---|---|
The format of the supplied NINO field is not valid. |
400 (Bad Request) |
FORMAT_NINO |
The format of the type of business field is not valid. |
400 (Bad Request) |
FORMAT_TYPE_OF_BUSINESS |
The format of the business ID field is not valid. |
400 (Bad Request) |
FORMAT_BUSINESS_ID |
The format of the From date field is not valid. |
400 (Bad Request) |
FORMAT_FROM_DATE |
The format of the To date field is not valid. |
400 (Bad Request) |
FORMAT_TO_DATE |
The format of the status field is not valid. |
400 (Bad Request) |
FORMAT_STATUS |
The From date parameter is missing. |
400 (Bad Request) |
MISSING_FROM_DATE |
The To date parameter is missing. |
400 (Bad Request) |
MISSING_TO_DATE |
The To date is before the From date. |
400 (Bad Request) |
RANGE_TO_DATE_BEFORE_FROM_DATE |
The Type of Business parameter is missing. |
400 (Bad Request) |
MISSING_TYPE_OF_BUSINESS |
The date range is longer than 366 days. |
400 (Bad Request) |
RULE_DATE_RANGE_INVALID |
The From date specified is before 2017-04-06. |
400 (Bad Request) |
RULE_FROM_DATE_NOT_SUPPORTED |
The client or agent is not authorised. This is because: the client is not subscribed to MTD, the agent is not subscribed to Agent Services, or the client has not authorised the agent to act on their behalf. |
403 (Forbidden) |
CLIENT_OR_AGENT_NOT_AUTHORISED |
The matching resource is not found. |
404 (Not Found) |
MATCHING_RESOURCE_NOT_FOUND |
No obligations found using this filter. |
404 (Not Found) |
NO_OBLIGATIONS_FOUND |
For error scenarios that are common across all APIs, and for error formats, see our reference guide.
Test data
Scenario simulations using Gov-Test-Scenario headers is only available in the sandbox environment.
Header Value (Gov-Test-Scenario) | Scenario |
---|---|
N/A - DEFAULT |
Simulate a success response. |
OPEN |
Simulate a success response with an open obligation. |
FULFILLED |
Simulate a success response with a fulfilled obligation. |
NOT_FOUND |
Simulate a scenario where no data is found. |