List your jobs
List your recent jobs to find results you did not receive, such as a callback that never arrived. The list returns one page at a time, newest first, so read it in a loop until no next page is left.
Before you start
- An access token, from Get an access token.
- For gRPC, the client code from Step 1 of the quickstart, generated again with
npx buf generateso that it haspageSizeandpageToken. Client code generated before then sends neither field and reads only the first page. - For the gRPC command in Step 1, the
bufCLI (external link).
Step 1: Read one page
Ask for a page of up to page_size jobs. The default is 50 and the maximum is 100; a larger value is treated as 100.
- REST
- gRPC
curl "https://partner.api.sasha.eu/jobs?page_size=100" \
-H "Authorization: Bearer <access-token>"
{
"jobs": [
{
"job_id": "01a14496-4060-7e4a-9c2b-5d6e7f8a9b0c",
"type": "lookup-signature",
"status": "completed",
"signature_id": "12345678901234567890",
"creator_id": 123,
"guidance": {
"share_state": "private",
"advice": "not_allowed"
},
"created_at": "2026-10-16T12:01:00Z",
"updated_at": "2026-10-16T12:01:02Z"
}
],
"next_page_token": "<next-page-token>"
}
buf curl --protocol grpc \
-H "Authorization: Bearer $TOKEN" \
--data '{"pageSize": 100}' \
https://partner.api.sasha.eu/sasha.partnerapi.v1.PartnerAPI/ListJobs
The response holds jobs and, when more pages follow, nextPageToken. Call the gRPC API shows how to set TOKEN.
next_page_token is an opaque string. Send it back unchanged as page_token to read the next page. When next_page_token is absent or empty, you have read the last page. A page can hold fewer jobs than page_size, or none, and still have a next page, so stop on the token, never on the page size.
Step 2: Read every page
- REST
- gRPC
This Node.js script, saved as list-jobs.mjs, reads every page and prints each job. Run it with SASHA_ACCESS_TOKEN set to an access token:
const listAllJobs = async (accessToken) => {
const jobs = [];
let pageToken = "";
do {
const url = new URL("https://partner.api.sasha.eu/jobs");
url.searchParams.set("page_size", "100");
if (pageToken) url.searchParams.set("page_token", pageToken);
const response = await fetch(url, {
headers: { Authorization: `Bearer ${accessToken}` },
});
if (!response.ok) {
throw new Error(`List Jobs failed with ${response.status}: ${await response.text()}`);
}
const page = await response.json();
jobs.push(...page.jobs);
pageToken = page.next_page_token ?? "";
} while (pageToken);
return jobs;
};
for (const job of await listAllJobs(process.env.SASHA_ACCESS_TOKEN)) {
console.log(job.job_id, job.type, job.status);
}
Save this as list-jobs.js in the quickstart folder, and run it with SASHA_CLIENT_ID and SASHA_CLIENT_SECRET set. It needs client code generated with pagination, as Before you start says; older code drops pageSize and pageToken without an error and reads only the first page. The first request leaves pageToken unset:
import { createClient } from "@connectrpc/connect";
import { createGrpcTransport } from "@connectrpc/connect-node";
import { PartnerAPI } from "./gen/sasha/partner-api/v1/partner_api_pb.js";
import { Job_Status, Job_Type } from "./gen/sasha/partner-api/v1/job_pb.js";
const client = createClient(
PartnerAPI,
createGrpcTransport({ baseUrl: "https://partner.api.sasha.eu" })
);
const { accessToken } = await client.authenticateWithClientCredential({
clientId: process.env.SASHA_CLIENT_ID,
clientSecret: process.env.SASHA_CLIENT_SECRET,
});
const callOptions = { headers: { Authorization: `Bearer ${accessToken}` } };
let pageToken;
do {
const page = await client.listJobs({ pageSize: 100, pageToken }, callOptions);
for (const job of page.jobs) {
console.log(job.jobId, Job_Type[job.type], Job_Status[job.status]);
}
pageToken = page.nextPageToken || undefined;
} while (pageToken);
A 400 on REST, or INVALID_ARGUMENT on gRPC, with the reason PAGE_TOKEN_INVALID means the page_token was not one the API returned. Retrying with the same token fails the same way; start again from the first page, without page_token.
The list holds only recent jobs: a job stays in it for 48 hours after it last changed status, the same window in which GetJob and WatchJob find it. The list is not a snapshot. A job created while you read the pages can appear on a later page or be missed. A job that leaves the 48-hour window while you read is left out of the pages after that. To catch new jobs, start again from the first page.
See also
- Set up callback notifications: receive each job as it finishes, so you list jobs only to reconcile
- Security and privacy: how long SASHA keeps each kind of data
- Go live: the checks before you switch to production credentials