This version is in beta - expect some breaking changes.

Self-Employment Business (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 allows developers to:

  • create or amend a self-employment annual summary for a tax year
  • retrieve a self-employment annual submission for a tax year
  • delete the self-employment annual submission for a tax year
  • create a self-employment period summary for submission of periodic data
  • amend a self-employment period summary
  • retrieve a single self-employment period summary for a given identifier
  • retrieve a list of all self-employment period summaries

Mapping APIs to Self Assessment tax return forms

Some parameters in this API map to box numbers in one or more Self Assessment tax return forms. To learn more and to download this mapping information as a CSV file, go to income-tax-mtd-changelog/mapping on GitHub.

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"         }     ] }

Where it is possible for the same error to be returned multiple times, message will describe the expected format and paths will show the fields which are invalid.

Where arrays are submitted a number indicates the object in the array sequence, for example, /arrayName/1/fieldName

An example with single error:
{     "code": "FORMAT_STRING_NAME",     "message": "The provided field is not valid",     "paths": [ "/arrayName/0/fieldName" ] }

An example with multiple errors: {     "code": "INVALID_REQUEST",     "message": "Invalid request",     "errors": [      {      "code": "FORMAT_VALUE",      "message": "The field should be between 0 and 99999999999.99",      "paths": [ "/objectName/fieldName1", "/arrayName/0/fieldName2" ]      },      {      "code": "FORMAT_STRING_NAME",      "message": "The provided field is not valid",      "paths": [ "/arrayName/0/fieldName3", "/arrayName/1/fieldName3" ]      }     ] }

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.

For versions 1.0 and later, Gov-Test-Scenario values that are not supported by the sandbox will result in a status code 400 response with an error code of RULE_INCORRECT_GOV_TEST_SCENARIO.

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.

Stateful

Some endpoints support STATEFUL gov test scenarios. Stateful scenarios work with groups of endpoints that represent particular types of submissions. For each type you can POST (or PUT) to submit or amend data, GET to retrieve or list data and DELETE to delete data. For example, with a STATEFUL gov test scenario a retrieval will return data based on what you submitted.

The following groups are stateful in the sandbox:

  • Self-Employment Annual Submission V2.0
  • Self-Employement Period Summaries V2.0

Dynamic

Some endpoints support DYNAMIC gov test scenarios. The response is dynamic based on the request parameters:

  • List Self-Employment Period Summaries V2.0
  • Retrieve a Self-Employment Period Summary V3.0

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.

Endpoints

View API endpoints
Why do these endpoints look different?

The endpoints for this API now use the Open API Specification (OAS).

The API has not changed. You do not need to make any updates to your application if you already use this API.