This version is in beta - expect some breaking changes.
National Insurance 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|
This API retrieves an annual summary of an individual taxpayer's class 1 total earnings and class 2 National Insurance contributions due for a given tax year.
Its primary use is for the calculation of a self-employed taxpayer's National Insurance liability within the Self Assessment tax calculation.
Data is available for taxpayers who, in the given tax year, have:
- self-employment income
- self-employment and employment income
Class 1 NICable earnings data is not available until Class 1 NICs reconciliation is complete. This starts in May and is usually complete by the end of August. Before reconciliation, Class 1 NICable earnings is returned as £0.00.
Class 2 NI contributions data should be available immediately at the end of the relevant tax year. However it can change after that date due to Class 1 NICs reconciliation or if we receive late changes from the taxpayer.
Find out more about National Insurance.
The endpoint in this API is user-restricted. Your users must grant authority for your software to access it by signing in to their HMRC online account.
The API supports individual and agent users. Note that:
- Individual users can only access their own information.
- Agent users can only access their own clients’ data.
The following options are supported for agents:
Option 1: Agent services account
Option 2: HMRC online services for agents account
If the agent uses an HMRC online services for agents account which is enrolled for Self Assessment for Agents, they will be able to access their existing 64-8 clients (restricted to 2 years’ history).
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.
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.