spicrawlspicrawlDocs
Partner

Assign credits to a user

Moves credits from the partner's balance to this user's own balance.

Requires scope: partner

POST
/v1/partner/workspaces/{external_user_id}/credits

Moves credits from the partner's balance to this user's own balance. The user spends them after their free credits and before the partner's balance. They do not reset each month. The funded balance reaches requests at once on the API process that took the assignment, and within about 5 seconds on the others.

Idempotent per idempotency_key: a repeat with the same key, the same credits and the same user returns "applied": false and changes nothing. A key reused with a different amount or user is 409 ERR::REQUEST::CONFLICT and changes nothing. The partner can assign at most its balance (funded less spent, never the credit line). More than that is 402 ERR::LIMIT::QUOTA_EXCEEDED. The partner's record of the assignment is a transfer out, and the workspace's is a transfer in.

Authorization

bearerAuth
AuthorizationBearer <token>

Authorization: Bearer <key>. Read the key from the SPICRAWL_API_KEY environment variable; never hard-code or log it. spicrawl_test_… keys can never spend live credits. Scopes: scrape, batch, sessions (granted by default), browser and read (granted deliberately), and partner (only on a partner account's key). A missing scope is 403 ERR::AUTH::INSUFFICIENT_SCOPE naming the scope.

In: header

Path Parameters

external_user_id*string

The partner's own id for the end user.

Match^[A-Za-z0-9._:-]{1,128}$

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X POST "https://example.com/v1/partner/workspaces/string/credits" \  -H "Content-Type: application/json" \  -d '{    "credits": 1,    "idempotency_key": "string"  }'
{  "external_user_id": "string",  "credits": 0,  "applied": true,  "user_credits": 0,  "balance_available": 0}