LeapOCRLeapOCR DocsAPI, SDKs, and integration guides

Delete OCR Job

Delete a job and remove all its associated data

Delete OCR Job

Delete a job and remove all its associated data. Jobs are automatically deleted after 7 days, but you can delete them immediately to remove sensitive data or free up resources.

Endpoint

DELETE /ocr/delete/{job_id}

Parameters

ParameterTypeRequiredDescription
job_idstringYesOCR job ID to delete

Important: Deletion is irreversible. Once deleted, the job content is permanently redacted and cannot be recovered.

SDK Examples

# Delete a job
curl -X DELETE https://api.leapocr.com/api/v1/ocr/delete/job_abc123 \
  -H "X-API-Key: your-api-key"

# Response:
# {
#   "message": "Job deleted successfully"
# }
import { LeapOCR } from "leapocr";
import { z } from "zod";

const InvoiceSchema = z.object({
  invoice_number: z.string(),
  total: z.number(),
});

const client = new LeapOCR({
  apiKey: process.env.LEAPOCR_API_KEY,
});

// Process document
const job = await client.ocr.processURL("https://example.com/invoice.pdf", {
  format: "structured",
  schema: z.toJSONSchema(InvoiceSchema),
});

// Wait for completion and get results
const result = await client.ocr.waitUntilDone(job.jobId);
const fullResult = await client.ocr.getJobResult(job.jobId);

// Use the extracted data
console.log("Extracted data:", fullResult.pages);

// Delete the job immediately after use
await client.ocr.deleteJob(job.jobId);
console.log("Job deleted successfully");
import asyncio
import os
from leapocr import LeapOCR, ProcessOptions, Format

async def main():
    async with LeapOCR(os.getenv("LEAPOCR_API_KEY")) as client:
        # Process document
        job = await client.ocr.process_url(
            "https://example.com/invoice.pdf",
            options=ProcessOptions(
                format=Format.STRUCTURED,
                schema={
                    "type": "object",
                    "properties": {
                        "invoice_number": {"type": "string"},
                        "total": {"type": "number"},
                    },
                },
            ),
        )

        # Wait for completion and get results
        result = await client.ocr.wait_until_done(job.job_id)

        # Use the extracted data
        print(f"Extracted data: {result.pages[0].result}")

        # Delete the job immediately after use
        await client.ocr.delete_job(job.job_id)
        print("Job deleted successfully")

asyncio.run(main())
package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "github.com/leapocr/leapocr-go"
)

func main() {
    client, err := ocr.New(os.Getenv("LEAPOCR_API_KEY"))
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    // Process document
    job, err := client.ProcessURL(ctx,
        "https://example.com/invoice.pdf",
        ocr.WithFormat(ocr.FormatStructured),
        ocr.WithSchema(map[string]interface{}{
            "type": "object",
            "properties": map[string]interface{}{
                "invoice_number": map[string]string{"type": "string"},
                "total":          map[string]string{"type": "number"},
            },
        }),
    )
    if err != nil {
        log.Fatal(err)
    }

    // Wait for completion and get results
    result, err := client.WaitUntilDone(ctx, job.ID)
    if err != nil {
        log.Fatal(err)
    }

    // Use the extracted data
    fmt.Printf("Extracted data: %+v\n", result.Data)

    // Delete the job immediately after use
    err = client.DeleteJob(ctx, job.ID)
    if err != nil {
        log.Printf("Failed to delete job: %v", err)
    } else {
        fmt.Println("Job deleted successfully")
    }
}

Response

{
  "message": "Job deleted successfully"
}

Error Responses

Status CodeDescription
200Job deleted successfully
400Bad request - invalid job ID
401Unauthorized - authentication required
404Not found - job does not exist or already deleted
500Internal server error

Automatic Deletion

Automatic Cleanup: All jobs and their associated files are automatically deleted after 7 days for security and storage management.

Jobs are automatically cleaned up after 7 days, but you can delete jobs immediately if needed.

Best Practices

1. Delete Sensitive Data Immediately

// Process and delete immediately
const job = await client.ocr.processFile("./medical-record.pdf");
const result = await client.ocr.waitUntilDone(job.jobId);

// Extract and save data locally
const extractedData = await client.ocr.getJobResult(job.jobId);
saveToDatabase(extractedData);

// Delete job immediately
await client.ocr.deleteJob(job.jobId);

2. Error Handling

try {
  await client.ocr.deleteJob(jobId);
  console.log("Job deleted successfully");
} catch (error) {
  if (error.status === 404) {
    console.log("Job already deleted or doesn't exist");
  } else {
    console.error("Failed to delete job:", error.message);
  }
}

What Gets Deleted

When you delete a job:

  • ✅ All extracted text and structured data
  • ✅ Original uploaded files
  • ✅ Processing metadata
  • ✅ Page-level results
  • ❌ Job record (marked as deleted but retained for audit)

The job record remains for audit purposes but all content is permanently redacted and cannot be recovered.

Next Steps

On this page