Testing the Asana API with a personal access token

Asana's API is a clean REST API with two habits to learn: every response is wrapped in data, and by default you get only a few fields back. Ask for the fields you want with opt_fields, and the rest is ordinary REST testing.

Step 1: Token and environment

In Asana, My settings ▸ Apps ▸ Developer apps ▸ Create new token. Use a test workspace or a project nobody else watches.

VariableValue
baseUrlhttps://app.asana.com/api/1.0
asanaTokenthe token, marked as secret
projectGidthe id of a test project (from its URL)

Authorization: Bearer token with {{asanaToken}}.

Step 2: Me and my workspaces

HTTP
GET {{baseUrl}}/users/me?opt_fields=name,email,workspaces.name
JavaScript
const me = pm.response.json().data;
pm.test('token works', () => pm.expect(me.gid).to.be.ok);
pm.environment.set('workspaceGid', me.workspaces[0].gid);

Asana ids are called gid and are strings. Keep them as strings; some are too large for a JavaScript number anyway.

Step 3: Create a task

HTTP
POST {{baseUrl}}/tasks?opt_fields=name,completed,projects.name,due_on
Content-Type: application/json

{"data": {"name": "API test {{$timestamp}}", "projects": ["{{projectGid}}"], "due_on": "2026-12-31", "notes": "Created by API tests"}}
JavaScript
const task = pm.response.json().data;
pm.test('task created', () => {
  pm.expect(pm.response.code).to.equal(201);
  pm.expect(task.completed).to.equal(false);
  pm.expect(task.due_on).to.equal('2026-12-31');
});
pm.environment.set('taskGid', task.gid);

Forgetting the data wrapper is the most common mistake here: Asana answers 400 with "missing data" or ignores the fields.

Step 4: Complete it

HTTP
PUT {{baseUrl}}/tasks/{{taskGid}}
Content-Type: application/json

{"data": {"completed": true}}
JavaScript
pm.test('completed', () => pm.expect(pm.response.json().data.completed).to.equal(true));

Step 5: Pagination

HTTP
GET {{baseUrl}}/projects/{{projectGid}}/tasks?limit=100&opt_fields=name,completed
JavaScript
const next = pm.response.json().next_page;
if (next) pm.environment.set('offset', next.offset);

Pass &offset={{offset}} for the next page. Without limit, some list endpoints return everything at once, and on a large project that's slow or refused, so always set it.

Step 6: Errors

JavaScript
// "Get a task that doesn't exist": expected failure
pm.test('not found', () => {
  pm.expect(pm.response.code).to.equal(404);
  pm.expect(pm.response.json().errors[0].message).to.be.a('string');
});
StatusCause
400invalid body, often the missing data wrapper
401bad token
403the token's user can't see that workspace or project
404wrong gid, or no access
429rate limited; Retry-After says how long

Delete the task in a cleanup step with DELETE {{baseUrl}}/tasks/{{taskGid}}.