Skip to content

Test with Postman

This page is a step-by-step guide with screenshots. Follow the steps in order. Select a picture to open it at full size.

Postman gives you two collections in one public workspace. Part 1, Try our API, sends signed test events to the MarsX sandbox, so you see a real 202 before you write sender code. Part 2, Check your endpoints (optional), calls the four endpoints, if you host them, the way MarsX does, so you can fix problems before MarsX runs its tests.

The workspace is MarsX Lead Intake API. Fork the collections and environments there, or download the files on this page and import them. See Without the Postman website.

The collection sends nine requests to the sandbox. Its script signs every event, refuses a base_url that is not https, and does not follow redirects. It takes about 10 minutes.

Files: collection and sandbox environment.

Before you start, collect the four values from the sandbox console: connection (the connection reference), signing_secret (the Signing secret), status_client_id (the Status client ID) and status_client_secret (the Status secret). The last three are in the dialog Your test key, shown once when you choose Make a test key.

Open the MarsX Lead Intake API workspace in your browser. The sidebar lists two collections, and below them the two environments. Badge 1 is the sandbox collection, used in Part 1. Badge 2 is the endpoint check, used in Part 2.

The Postman workspace MarsX Lead Intake API. The sidebar lists two collections and two environments. Box 1 marks the sandbox collection. Box 2 marks the check your endpoints collection.
The public workspace, with its collections and environments. Badge 1 is the sandbox collection. Badge 2 is the endpoint check.

2. Open the menu of the sandbox collection

Section titled “2. Open the menu of the sandbox collection”

Click the three dots (...) next to MarsX Lead Intake API: sandbox. Choose Fork.

The three dots menu of the sandbox collection, with the Fork item highlighted.
The collection menu, with Fork highlighted.

If your menu shows Use / Fork instead of Fork, choose Use / Fork. Newer Postman versions use that name.

The collection menu in newer Postman, where the item is called Use / Fork and is highlighted.
In newer Postman the menu item is called Use / Fork.

A Use panel then opens, instead of the form in step 3. Keep Fork selected under Use as. Fill in the panel in the order of the badges:

  • Badge 1, Workspace. Choose your own workspace.
  • Badge 2, Fork label. Type a name, for example Sandbox tests.
  • Badge 3, Environments to fork. Select MarsX sandbox.
  • Badge 4. Tick Pull changes from the source collection automatically. This brings in MarsX’s later updates.
  • Badge 5. Click Use Collection. Then go to step 4.
The Use panel for a collection. Five red boxes mark the workspace, the fork label, the environments to fork, the pull changes tick box and the Use Collection button.
The Use panel, shown for the endpoint check collection.

If the Fork collection form opens, fill it in the order of the badges:

  • Badge 1, Fork label. Type a name, for example Sandbox tests.
  • Badge 2, Workspace. Choose your own workspace.
  • Badge 3, Environments to fork. Select MarsX sandbox.
  • Badge 4. Click Fork Collection.
The Fork collection form. Four red boxes mark the fork label, the workspace, the environments to fork and the Fork Collection button.
The Fork collection form. The badges give the order.

With the newer Use panel, Postman sometimes does not copy the environment, even when you selected one. In your own workspace, open Environments. If MarsX sandbox is there, go to step 5.

If MarsX sandbox is missing, fork it on its own. Go back to the MarsX workspace. Under Environments in the sidebar, click the three dots next to MarsX sandbox. Choose Fork. In the form that opens, choose your own workspace.

The Environments list of the MarsX workspace, with the three dots menu of an environment open and Fork highlighted.
Forking an environment on its own: Environments, three dots, Fork.

5. Type your four values into the environment

Section titled “5. Type your four values into the environment”

Open your forked MarsX sandbox environment. Type the four values from Concour into the Value column, as the badges show. base_url and lead_prefix are already set. Leave them as they are.

A value that you typed shows no cloud icon, so it stays on your computer. Keep it that way. Never press Share on this environment.

  • Badge 1. connection.
  • Badge 2. signing_secret. It shows as dots.
  • Badge 3. status_client_id.
  • Badge 4. status_client_secret. It shows as dots.
The forked environment. Red boxes 1 to 4 mark the Value cells of connection, signing_secret, status_client_id and status_client_secret. The secrets show as dots. The connection and the client id are blurred.
Type the four values in the Value column. The secrets show as dots.

Click the environment picker at the top right (badge 1). Choose MarsX sandbox (badge 2). Your fork label may show beside the name.

The environment picker at top right, open. The item MarsX sandbox, with the fork label Sandbox tests, is ticked.
The environment picker. Badge 1 opens it. Badge 2 is the choice.

Click the three dots next to your fork of MarsX Lead Intake API: sandbox. Choose Run. The same menu holds Pull changes, which you use to get MarsX’s later updates.

The collection menu with the Run item highlighted. The same menu holds Fork, Create pull request, Merge changes and Pull changes.
The collection menu, with Run highlighted.

Keep all nine requests selected, in their order. The Runner shows “9 of 9 selected” (badge 1). Click Start run (badge 2). A run takes about half a minute.

The Postman Runner listing the nine requests, all ticked. Box 1 shows 9 of 9 selected. Box 2 marks the Start run button.
The Runner with all nine requests selected. Click Start run.

When the run ends, read the totals. The target is All tests 26, Passed 26, Failed 0. Click a request to see MarsX’s answer on the right. The picture shows a 202 with "result": "accepted".

Run results with All tests 26, Passed 26 and Failed 0. A 202 response with the result accepted is open on the right.
A good run: 26 passed, 0 failed. The right panel shows MarsX's answer.

Each run uses new lead ids, so you can run it again. Compare each request with this table:

Request Expected
1. lead.new 202, accepted
2. Same webhook-id again 202, duplicate
3. lead.update, revision 2 202, accepted
4. lead.withdraw 202, accepted. Request 3 may read quarantined
5. lead.delete, second lead 202, accepted
6. Scenario 503 503, Retry-After: 1
7. Scenario drop-202 504, Retry-After: 1
8. Status token 200, Bearer token
9. Status read of request 1 200 with a processing_state: queued at first, then applied

Every test should pass. Request 3 may read quarantined because the withdrawal in request 4 restricts the lead. This is intended. See Revisions and privacy events.

The collection does not replace sandbox steps 1 and 4. Check your signing code offline against the test vector, and send a bad signature and an old timestamp yourself. See Test in the sandbox.

This part is optional. Do it only if you host the four endpoints. Going live does not need them. Do this once your four endpoints run in your sandbox: the OAuth token URL, GET /v1/changes, GET /v1/privacy-events and GET /v1/leads/{partner_lead_id}. The second collection calls them the way MarsX does and shows where they differ from the contract. This collection only calls your sandbox, never a MarsX host.

MarsX still runs its own tests afterwards (Test your endpoints). Run this check before you ask for them.

Files: collection and environment. In the workspace they are MarsX Lead Intake API: check your endpoints and MarsX endpoint check.

Fork the collection MarsX Lead Intake API: check your endpoints. It is badge 2 in Part 1, step 1. Use the same menu and form as in Part 1, steps 2 and 3. In the form, select the environment MarsX endpoint check. If the environment does not come along, fork it on its own, as in Part 1, step 4.

Open your MarsX endpoint check environment. Use your sandbox and invented data. Fill in the four groups, as the badges show:

  • Badge 1. partner_base_url and partner_token_url: the addresses of your sandbox.
  • Badge 2. marsx_client_id and marsx_client_secret: the read-only OAuth client you will give MarsX. scope is your read scope, leads:read unless you named another.
  • Badge 3. test_lead_id is a live lead. withdrawn_lead_id is a lead you hold that withdrew consent or asked for restriction. erased_lead_id is a lead you erased and no longer hold.
  • Badge 4. expired_changes_cursor and expired_privacy_cursor: the two cursors that always answer 410, one per feed. You give MarsX the same two for test R4.
The endpoint check environment in four groups. Box 1 holds your sandbox addresses. Box 2 holds the read-only OAuth client and the scope. Box 3 holds three test lead ids. Box 4 holds two expired cursors. The values are blurred.
The endpoint check environment, in four groups. The values are blurred.

Type the client secret as in Part 1, step 5, and never press Share. The two addresses must start with https://. Only http://localhost and http://127.0.0.1 are allowed over plain http, for local testing. For any other address, the collection sends nothing. It never follows a redirect, and a 3xx answer fails a test.

Select MarsX endpoint check at the top right, as in Part 1, step 6. Open the Runner and start the run, as in Part 1, steps 7 and 8. Keep all requests selected, in order.

Request 1 fetches the token that the other requests use. Request 4 pages through the whole changes feed, so one single send reads one page only.

Request What it checks MarsX test
1. Token: valid client 200 with access_token, token_type Bearer and expires_in between 300 and 86400 All
2. Token: wrong secret 401 with invalid_client All
3. changes: first page 200, the ChangesPage shape, a non-empty next_cursor, a default page size of at least 100 R1
4. changes: page through the whole feed limit=500 until has_more is false: oldest first, no repeated partner_lead_id and source_revision pair, next_cursor on the last page R2
5. changes: limit above the maximum 400 for limit=999999 R2
6. changes: expired cursor 410 with the problem type urn:marsx:problem:cursor-expired R4
7. privacy-events: first page 200, the PrivacyEventsPage shape, no contact or profile data in any item R1, R3
8. privacy-events: expired cursor 410 with urn:marsx:problem:cursor-expired R4
9. leads: a live lead 200, the LeadData shape, source_revision and updated_at present R1, R2
10. leads: a withdrawn lead 200 with the withdrawal form and no contact data R1
11. leads: an erased lead 404 as application/problem+json R3
12. No token 401 and no feed data All
13. Bad token 401 All

When the run ends, read the totals. The target is Passed 90, Failed 0.

Endpoint check results with All tests 90, Passed 90 and Failed 0.
A passing endpoint check: 90 passed, 0 failed.

If a test fails, select the Failed filter. Each failure names the request and gives the status expected and the status received. In the picture below, requests 6 and 8 got 400 where 410 was expected. Request 11, an erased lead, got 200 where 404 was expected.

Endpoint check results filtered to Failed. Three failures are listed, each with the expected and the actual status code.
Failures, with the Failed filter on. Each shows the expected and the actual status.

Compare each failed request with the pages that describe the endpoint: Token URL, Changes and privacy events and Lead lookup. Fix the difference. Then run the collection again.

The collection cannot check test R5 (the privacy list after an expired privacy-events cursor), or a valid token without the scope getting 403. It cannot check your request limits either. Nor can it check whether 1,001 or more changes with one updated_at survive a restart between pages. MarsX checks those.

When every request passes, give MarsX your base URL, token URL and read-only client in Concour, under Your endpoints (the secret is saved and never shown again). Seed the data for tests R1 to R5. See Test your endpoints.

To skip forking, import the files. In Postman, choose Import and select the collection and its environment. Then follow the steps from Part 1, step 5. Insomnia and Bruno import Postman collections too, but their script support differs, so check them against the test vector on Sign requests.

The command lines run the same files. Newman is the command-line runner for Postman collections. Download both files into one folder, then run:

Terminal window
npx newman run marsx-lead-intake.postman_collection.json -e marsx-sandbox.postman_environment.json

The downloaded environment has empty secrets. Supply them with --env-var, and read them from your shell so they stay out of files:

Terminal window
npx newman run marsx-lead-intake.postman_collection.json \
-e marsx-sandbox.postman_environment.json \
--env-var "connection=$MARSX_CONNECTION" \
--env-var "signing_secret=$MARSX_SIGNING_SECRET" \
--env-var "status_client_id=$MARSX_STATUS_CLIENT_ID" \
--env-var "status_client_secret=$MARSX_STATUS_CLIENT_SECRET"

The Postman CLI runs the same files from disk. Add --no-report-events, so that it uploads no report:

Terminal window
postman collection run marsx-lead-intake.postman_collection.json \
-e marsx-sandbox.postman_environment.json --no-report-events

If MarsX changes a collection, click the three dots next to your fork. Choose Pull changes. The menu is the one in Part 1, step 7.

  • The menu says Use / Fork, not Fork. Choose Use / Fork. Part 1, step 2 shows the panel.
  • The environment is missing after forking. Fork it on its own. Part 1, step 4 shows how.
  • A request is red. Open it and read the line that starts with FAIL. It gives the status expected and the status received.
  • The collection says base_url must start with https://. It refuses to send anything. Set base_url to https://api-sandbox.marsx.media. In Part 2, the same rule applies to partner_base_url and partner_token_url.