How are credits spent for async jobs?
Every time you run a job, the system takes the 1st page
of the document and returns the credit spent in the credits
parameter that you see in the output. If the job/check
is successful it consumes credits for the job/check
call + credits for the remaining pages.
For example:
- You have an input: PDF with 10 pages
- You call
pdf/edit/add
to add text on 3 pages withasync: true
. - This call takes 21 credits (1st page)
(1 out of 3)
- After 10 seconds you run
job/check
. It returns a success status. - Your credit spent will show 44 credits.
-
job/check
= 2 credits -
pdf/edit/add
= 21 credits /page * 2 pages (for 2 remaining pages)(3 out of 3)
- If
job/check
returns failed, aborted or invalid status, the job stops and the system returns used credits back to your account. - All further
job/check
calls orjob/check
withworking
status will consume few credits per call just forjob/check
.
Why job/check
call also consumes credits? The job/check
call takes a very small number of credits by design to prevent users from running job/check
at a very high rate.
If you are processing large documents that can take 1-2 minutes to process, we recommend putting larger delays before the next job/check
call. For example, if you run OCR for a scanned document: created an async job, make a delay for 60-100 seconds, and run job/check
call.
You can always explore the total number of credits spent per async job at the API logs page at https://app.pdf.co/account/logs/api