How to test Agent Authorisation API?

Prerequisites

  1. Login to API developer hub and create a sandbox application
  2. Make note of your clientID from API developer Hub.

Create a client on Agent Stubs

  1. Navigate to agents stubs UI https://test-www.tax.service.gov.uk/agents-external-stubs/gg/sign-in

  2. Sign in with any UserID and use hmrc as Planet

  3. Select Affinity Group as Individual
  4. Select Principal enrolment as HMRC-MTD-IT

  5. Click Create and Continue
  6. Change Credential Strength to Strong

  7. Change Confidence Level to 200

  8. If you need MTD-VAT enrolment for the same client, add new Principal Enrolment as HMRC-MTD-VAT
  9. Click Update
  10. client001 home page is displayed

  11. Click on Identifier value corresponding to HMRC-MTD-IT

    • Verifier value = NINO to be used
    • Verifier value = Postcode to be used
  12. Click on client001 and click on identifier value corresponding to HMRC-MTD-VAT
    • Identifier value = VRN to be used

    • Identifier value = VATRegistrationDate to be used
      • Note that you will need to convert date from dd/mm/yy to yyyy-mm-dd
      • eg: 20/07/03 becomes 2003-07-03

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

Prerequisites

  • 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

  1. Navigate to https://test-www.tax.service.gov.uk/invitations/<clientType>/<uid>/<agent-name> in a separate tab

  2. Click continue and you will be served with the consent page

  3. Select check box for VAT and click Continue

    You will be served with check your answers page

  4. Click "Continue and send response"

  5. Success page should be served

  6. Go back to agents-external-stubs and click on “view” corresponding to the agent used to create an invitation.

  7. 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
Get help with this page. Get help with this page.