How to test Agent Authorisation API?
Prerequisites
- Login to API developer hub and create a sandbox application
- Make note of your clientID from API developer Hub.
Create a client on Agent Stubs
-
Navigate to agents stubs UI https://test-www.tax.service.gov.uk/agents-external-stubs/gg/sign-in
-
Sign in with any
UserID
and use hmrc asPlanet
- Select
Affinity Group
as Individual -
Select
Principal enrolment
as HMRC-MTD-IT - Click
-
Change
Credential Strength
to Strong -
Change
Confidence Level
to 200 - If you need MTD-VAT enrolment for the same client, add new
Principal Enrolment
as HMRC-MTD-VAT - Click
-
client001 home page is displayed
-
Click on Identifier value corresponding to HMRC-MTD-IT
- Verifier value = NINO to be used
- Verifier value = Postcode to be used
- Click on client001 and click on identifier value corresponding to HMRC-MTD-VAT
Test data for MTD-IT
{ "service":[ "MTD-IT" ], "clientType": "personal", "clientIdType":"ni", "clientId":"AB863145B", "knownFact":"OX1 3IK" }
Sample API call
curl -v -H "Accept: application/vnd.hmrc.1.0+json" -H 'content-type: application/json' -H "Authorization: Bearer 5946713224d32eab9615c47966a3b4" --data '{"service": ["MTD-IT"], "clientType": "personal", "clientIdType": "ni", "clientId": "AB863145B", "knownFact": "OX12 3IK"}' https://test-api.service.hmrc.gov.uk/agents/NARN0238758/invitations
Test data for MTD-VAT
Please note: clientType for MTD-VAT can be either personal or business.
{ "service":[ "MTD-VAT" ], "clientType":"business" "clientIdType":"vrn", "clientId":"102569784", "knownFact":"2003-07-20" }
curl -v -H "Accept: application/vnd.hmrc.1.0+json" -H 'content-type: application/json' -H "Authorization: Bearer 5946713224d32eab9615c47966a3b4" --data '{"service": ["MTD-VAT"], "clientType": "business", "clientIdType": "vrn", "clientId": "102569784", "knownFact":"2003-07-20"}' https://test-api.service.hmrc.gov.uk/agents/NARN0238758/invitations
Create agent-client relationship in agents-external-stubs
-
After creating an invitation you will need to call Get Invitation by Id and get the "clientActionUrl
Request
curl -v -H "Accept: application/vnd.hmrc.1.0+json" -H "Authorization: Bearer 5946713224d32eab9615c47966a3b4" https://test-api.service.hmrc.gov.uk/agents/NARN0238758/invitations/AOXB1SJTD9LXR
Json Response Body
{
"_links":{
"self":{
"href":"/agents/FARN0001132/invitations/AOXB1SJTD9LXR"
}
},
"created":"2019-02-07T10:50:58.844Z",
"expiresOn":"2019-02-17T00:00:00.000",
"arn":"FARN0001132",
"service":[
"MTD-IT"
],
"status":"Pending",
"clientActionUrl":"https://test-www.tax.service.gov.uk/invitations/personal/69BGN7CF/agency-test"
}
-
Make sure you are signed in with the client (client001) and planetID = hmrc
-
If you are already inside the stubs, you can sign-in to the client by clicking sign-in corresponding to client001
Steps
- Navigate to https://test-www.tax.service.gov.uk/invitations/<clientType>/<uid>/<agent-name> in a separate tab
-
Click continue and you will be served with the consent page
- Select check box for VAT and click Continue
You will be served with check your answers page
- Click "Continue and send response"
-
Success page should be served
-
Go back to agents-external-stubs and click on “view” corresponding to the agent used to create an invitation.
-
You should be able to see the relationship successfully created with the client in the Delegated enrolment section.
After creating an invitation you will need to call Get Invitation by Id and get the "clientActionUrl
Request
curl -v -H "Accept: application/vnd.hmrc.1.0+json" -H "Authorization: Bearer 5946713224d32eab9615c47966a3b4" https://test-api.service.hmrc.gov.uk/agents/NARN0238758/invitations/AOXB1SJTD9LXR
Json Response Body
{ "_links":{ "self":{ "href":"/agents/FARN0001132/invitations/AOXB1SJTD9LXR" } }, "created":"2019-02-07T10:50:58.844Z", "expiresOn":"2019-02-17T00:00:00.000", "arn":"FARN0001132", "service":[ "MTD-IT" ], "status":"Pending", "clientActionUrl":"https://test-www.tax.service.gov.uk/invitations/personal/69BGN7CF/agency-test" }
Make sure you are signed in with the client (client001) and planetID = hmrc
If you are already inside the stubs, you can sign-in to the client by clicking sign-in corresponding to client001
Click continue and you will be served with the consent page
You will be served with check your answers page
Success page should be served
Go back to agents-external-stubs and click on “view” corresponding to the agent used to create an invitation.
You should be able to see the relationship successfully created with the client in the Delegated enrolment section.
Now you use that test data in get Relationship API
Test data for MTD-IT
{ "service":[ "MTD-IT" ], "clientIdType":"ni", "clientId":"AB863145B", "knownFact":"OX1 3IK" }Sample API call for check relationship (by providing bearer of the corresponding agent)
curl -v -H "Accept: application/vnd.hmrc.1.0+json" -H 'content-type: application/json' -H "Authorization: Bearer 5946713224d32eab9615c47966a3b4" --data '{"service": ["MTD-IT"], "clientIdType": "ni", "clientId": "AB863145B", "knownFact": "OX12 3IK"}' https://test-api.service.hmrc.gov.uk/agents/NARN0238758/relationships