Skip to content

Creating Test Users in the Sandbox

Jacob Brownlow edited this page Nov 25, 2021 · 5 revisions

As of 25th Nov 2021, the below setup is working:

Prerequisites:

  1. Setup vendor application on the Developer Hub for the Sandbox environment

  2. Subscribe your vendor application to the VAT APIs you are trying to test:
    VAT (MTD) API
    and the following:
    Create Test User API

Steps:

  1. Create a user using the /organisations Create Test User endpoint (Documentation)
    Alternatively use the Create Test User frontend

    Example response

    {
     "userId": "571213830501",
     "password": "aJ9so7mildjq",
     "userFullName": "Claude Venables",
     "emailAddress": "claude.venables@example.com",
     "organisationDetails": {
         "name": "Company UHNS5I",
         "address": {
             "line1": "16 Portobello Road",
             "line2": "Nottingham",
             "postcode": "TS5 1PA"
         }
     },
     "vrn": "966673662",
     "vatRegistrationDate": "2018-05-02"
    }
    

  1. Grant authority for your vendor application to act on behalf of the user (Documentation)

    Navigate to the grant authority URL

    • Use your application client_id
    • Use your application redirect_uri

    https://test-api.service.hmrc.gov.uk/
      oauth/authorize?response_type=code
        &client_id=
          &scope=read:vat+write:vat
            &redirect_uri=
    

    Login with the user's userId and password to grant authority


  1. Retrieve access token with /oauth/token endpoint (Documentation)

    Example response:

    {
     "access_token": "661a961bacea332f852d397a2dafc83",
     "refresh_token": "dbebf893f08bcb18bb91311a6a952881",
     "expires_in": 14400,
     "scope": "read:vat write:sent-invitations write:vat",
     "token_type": "bearer"
    }
    

  1. Using the vat-api (Documentation)

    • Use user's Authorization access_token returned in step 3
    • Use user's vrn from step 1

Clone this wiki locally