Check an image you found online
When your service finds an image on the web, such as in a moderation queue or a crawl, look it up to learn whether it carries a SASHA Signature and whether its owner allows it where you found it. Send the page along with the image: without it, SASHA cannot say whether a restricted image belongs there.
Before you start
- A Client ID and Client Secret, from Get access.
- For gRPC, the client code generated in Step 1 of the quickstart.
- The address of the image, and the address of the page that shows it. SASHA fetches the image itself, so its URL must be HTTPS, public, and answer without a redirect.
Step 1: Submit the lookup
Send three URLs:
media_url | The address SASHA downloads the image from |
publish_url | The page that shows the image, as a reader sees it in the browser |
source_url | The address the image bytes are served from, often the same as media_url |
- REST
- gRPC
Replace <access-token> with a token from POST /oauth/token:
curl https://partner.api.sasha.eu/signature/lookup \
-H "Authorization: Bearer <access-token>" \
-H "Content-Type: application/json" \
-d '{
"media_url": "https://cdn.example.com/images/abc.jpg",
"media_mime_type": "image/jpeg",
"publish_url": "https://news.example.com/articles/123",
"source_url": "https://cdn.example.com/images/abc.jpg"
}'
{
"job": {
"job_id": "3f9d2a61-5b7c-4e8d-9a0b-1c2d3e4f5a6b",
"type": "lookup-signature",
"status": "pending",
"created_at": "2026-10-16T10:00:00Z",
"updated_at": "2026-10-16T10:00:00Z"
}
}
A 400 means SASHA could not fetch media_url, or the request is not valid, and no job was created. A failed fetch is worth one retry; an invalid request is not.
On gRPC the two context URLs sit inside guidanceContext. Save this as check-image.js in the quickstart folder, and run it with SASHA_CLIENT_ID and SASHA_CLIENT_SECRET set:
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 } from "./gen/sasha/partner-api/v1/job_pb.js";
import { Guidance_Advice } from "./gen/sasha/common/public/guidance_pb.js";
import { ShareState } from "./gen/sasha/common/public/share_state_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}` } };
const { job } = await client.lookupSignatureFromURL(
{
mediaUrl: "https://cdn.example.com/images/abc.jpg",
mediaMimeType: "image/jpeg",
guidanceContext: {
publishUrl: "https://news.example.com/articles/123",
sourceUrl: "https://cdn.example.com/images/abc.jpg",
},
},
callOptions
);
console.log("Job ID:", job.jobId);
An INVALID_ARGUMENT means SASHA could not fetch mediaUrl, or the request is not valid, and no job was created.
Step 2: Read the result
- REST
- gRPC
Read the job until status is completed or failed, or send a callback_url with the lookup and let SASHA post it to you, as Set up callback notifications shows. Replace <job-id> with the job_id from Step 1:
curl https://partner.api.sasha.eu/jobs/<job-id> \
-H "Authorization: Bearer <access-token>"
{
"job_id": "3f9d2a61-5b7c-4e8d-9a0b-1c2d3e4f5a6b",
"type": "lookup-signature",
"status": "completed",
"signature_id": "12345678901234567890",
"creator_id": 123,
"guidance": {
"share_state": "restricted",
"advice": "not_allowed"
},
"created_at": "2026-10-16T10:00:00Z",
"updated_at": "2026-10-16T10:00:03Z"
}
Add this to the end of check-image.js. WatchJob closes the stream when the job finishes:
let finished;
for await (const { job: update } of client.watchJob({ jobId: job.jobId }, callOptions)) {
if (update.status === Job_Status.COMPLETED || update.status === Job_Status.FAILED) {
finished = update;
}
}
if (!finished) {
throw new Error(`The watch of job ${job.jobId} ended early: call WatchJob again`);
}
if (finished.status === Job_Status.FAILED) {
throw new Error(`Job failed: ${finished.error?.code} ${finished.error?.message}`);
}
if (!finished.signatureId) {
console.log("No SASHA Signature in this image");
} else if (!finished.guidance) {
console.log("Signature", finished.signatureId.value.toString(), "has no Guidance: revoked, or not evaluated");
} else {
console.log("SignatureID:", finished.signatureId.value.toString());
console.log("CreatorID:", finished.creatorId);
console.log("Share state:", ShareState[finished.guidance.shareState]);
console.log("Advice:", Guidance_Advice[finished.guidance.advice]);
}
A completed lookup is in one of three states:
signature_id is null | The image carries no SASHA Signature. |
signature_id and creator_id, no guidance | The image carries a Signature, and SASHA has revoked it or could not evaluate its Record. A Record that could not be evaluated may give Guidance on a later lookup. |
signature_id, creator_id and guidance | The image carries a Signature, and guidance says whether it belongs where you found it. |
creator_id names the business that owns the Signature. If you own it, or its owner granted you fields of its Record, the job also carries a record with those fields for 24 hours after it completes, as Who can read a Record describes.
Step 3: Act on the advice
Branch on guidance.advice, and on guidance.share_state where the advice alone is not enough:
allowed | The owner allows the image at this page and time. | Nothing: the image is where its owner allows it. |
not_allowed | The owner does not allow the image here, or now. A private share state means the owner allows it nowhere in public. | Hide the image, or send it to your review process, with the SignatureID and CreatorID. |
inconclusive | SASHA could not decide, because the Record restricts the image to some URLs and the lookup carried no publish_url or source_url. | Look the image up again with the page it was found on. |
Guidance reflects the distribution the owner declared to SASHA. It is not a ruling on the legal status of the image, so treat not_allowed as a signal for your own process, not as proof. Records explains how SASHA evaluates the Record.
See also
- How SASHA works: what a lookup returns
- Records: share states and how Guidance is evaluated
- Error handling: why a lookup job fails