POST
/
annotate
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<your-api-key>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    jobId: '123e4567-e89b-12d3-a456-426614174000',
    annotatedData: {
      name: 'John Doe',
      amount: '1500',
    },
    extractId: '123e4567-e89b-12d3-a456-426614174002',
  }),
};

fetch('https://api.getomni.ai/extract-annotations', options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));
{
  "success": true,
  "annotation": {
    "jobId": "123e4567-e89b-12d3-a456-426614174000",
    "documentUrl": "https://example.com/document.pdf",
    "originalData": {
      "name": "John Doe",
      "amount": "1000"
    },
    "annotatedData": {
      "name": "John Doe",
      "amount": "1500"
    },
    "createdAt": "2023-09-10T14:23:45.123Z",
    "updatedAt": "2023-09-10T14:23:45.123Z"
  }
}

This endpoint provides a unified interface for both creating new annotations and updating existing ones. The behavior is determined by whether you include the annotationId parameter.

Usage

  • Create new annotation: Omit the annotationId parameter to create a new annotation
  • Update existing annotation: Include the annotationId parameter to update an existing annotation

Request Body

jobId
string
required

The ID of the job the annotation belongs to

documentUrl
string
required

URL of the document being annotated

originalData
object
required

The original data extracted from the document. Required when creating a new annotation, optional when updating.

annotatedData
object
required

The annotated data with human corrections

annotationId
string

ID of an existing annotation to update. If provided, the endpoint will update an existing annotation. If omitted, a new annotation will be created.

extractId
string

The ID of the extract job associated with this annotation

extractExampleId
string

The ID of the extract example associated with this annotation

Response

success
boolean

Whether the annotation was saved successfully

annotation
object

The saved annotation data

const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<your-api-key>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    jobId: '123e4567-e89b-12d3-a456-426614174000',
    annotatedData: {
      name: 'John Doe',
      amount: '1500',
    },
    extractId: '123e4567-e89b-12d3-a456-426614174002',
  }),
};

fetch('https://api.getomni.ai/extract-annotations', options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));
{
  "success": true,
  "annotation": {
    "jobId": "123e4567-e89b-12d3-a456-426614174000",
    "documentUrl": "https://example.com/document.pdf",
    "originalData": {
      "name": "John Doe",
      "amount": "1000"
    },
    "annotatedData": {
      "name": "John Doe",
      "amount": "1500"
    },
    "createdAt": "2023-09-10T14:23:45.123Z",
    "updatedAt": "2023-09-10T14:23:45.123Z"
  }
}