Skip to main content

Quickstart Tutorial

In this guide, you'll protect your first image with SASHA Signature technology. By the end, you'll have a protected image and a SignatureID that uniquely identifies the protection.

Time to complete: ~10 minutes

What you'll do

  1. Get an access token from the Partner API
  2. Submit an image for protection
  3. Poll for job completion
  4. Download your protected image

What you'll need

  • Client ID and Client Secret from SASHA (see Prerequisites)
  • An image URL or local image file (JPEG or PNG)
  • Basic command-line knowledge
tip

This guide uses polling to check job status. For production use, we recommend setting up callbacks to receive automatic notifications when jobs complete.

gRPC Prerequisites

If you're using gRPC, you'll need nice-grpc (or your preferred gRPC client) and generated client code from SASHA .proto files.

Step 1: Get an Access Token

First, authenticate with the Partner API to get an access token.

Replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with your actual credentials:

curl -X POST https://partner.api.sasha.eu/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
-d "grant_type=client_credentials"

Response:

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600
}
info

Save the access_token value - you'll use it in the next steps. Tokens expire after the time specified in expires_in (in seconds).

Step 2: Submit Your Image for Protection

Now submit your image to the PartnerAPI for protection. We'll use a publicly accessible image URL.

curl -X POST https://partner.api.sasha.eu/signature/embed \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"media_url": "/img/sasha-logo-wall.jpeg",
"media_mime_type": "image/jpeg"
}'

Response:

{
"job": {
"job_id": "job_abc123xyz",
"type": "embed-signature",
"status": "pending",
"created_at": "2025-10-07T12:00:00Z",
"updated_at": "2025-10-07T12:00:00Z"
}
}
info

Save the job_id value - you'll use it to check the job status.

Alternative: Upload file directly

You can also upload a local file using multipart/form-data (REST) or the embedSignatureFromData streaming method (gRPC). See the API Reference for details.

Step 3: Poll for Job Completion

The embedding process takes a few seconds. Poll the job status until it's complete.

curl -X GET https://partner.api.sasha.eu/jobs/job_abc123xyz \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response (while processing):

{
"job_id": "job_abc123xyz",
"type": "embed-signature",
"status": "in_progress",
"created_at": "2025-10-07T12:00:00Z",
"updated_at": "2025-10-07T12:00:01Z"
}

Response (when complete):

{
"job_id": "job_abc123xyz",
"type": "embed-signature",
"status": "completed",
"output_url": "https://storage.sasha.eu/protected/abc123.jpg",
"output_url_expires_at": "2025-10-07T13:00:00Z",
"signature_id": "12345678901234567890",
"created_at": "2025-10-07T12:00:00Z",
"updated_at": "2025-10-07T12:00:05Z"
}
Polling best practice

Check the status every 1-2 seconds. Most jobs complete within 5-10 seconds.

Step 4: Download Your Protected Image

Once the job is complete, download the protected image.

curl -o protected-image.jpg "https://storage.sasha.eu/protected/abc123.jpg"
URL expiration

The output_url expires after the time specified in output_url_expires_at. Download your image before it expires!

✅ Success!

Congratulations! You've successfully protected your first image with SASHA. You should now have:

  • ✅ A job_id that tracked the embedding process
  • ✅ A signature_id (e.g., 12345678901234567890) that uniquely identifies this protection
  • ✅ A protected image that looks identical to the original but contains the embedded SASHA Signature

What you learned

  • How to authenticate with the Partner API using client credentials
  • How to submit an image for protection
  • How to poll for job completion
  • How to download the protected image

Look up the protection

If you want to verify the Signature was embedded, use the Lookup API:

curl -X POST https://partner.api.sasha.eu/signature/lookup \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"media_url": "[USE_OUTPUT_URL_FROM_STEP_3]",
"media_mime_type": "image/jpeg"
}'

Replace [USE_OUTPUT_URL_FROM_STEP_3] with the output_url you received in Step 3.

The returned signature_id should match the one from your embed job!

Common Issues

IssueSolution
401 UnauthorizedCheck your Client ID and Secret, or your access token may have expired
400 Bad Request with "media_url is required"Ensure you're sending the correct request format
Job status is failed with unsupported_formatCheck that your image is JPEG or PNG format
404 Not Found when downloading output_urlThe URL may have expired - check the expiration timestamp in the job response

Next Steps

Now that you've protected your first image, explore these topics:

Ready for production?

For production applications, we recommend:

  1. Using callbacks instead of polling for better performance
  2. Implementing token caching and proactive renewal
  3. Adding proper error handling and retry logic