# Affinda

> Send resumes, invoices and other documents to Affinda to read, then use the extracted data and organize the results.

App · 22 actions. Web page: https://docs.lodol.com/docs/integrations/affinda

## Actions

### Add tag to documents

Tag one or more documents.

**Inputs**

- Tag (`tag`, number, required): The tag's ID, from List tags or Create tag.
- Documents (`identifiers`, list, required): The IDs of the documents to tag.

**Outputs**

- `data` (object): Affinda's answer, empty when it worked.

**Example output**

```json
{
  "data": {}
}
```

### Create tag

Create a tag in a workspace.

**Inputs**

- Name (`name`, text, required): The tag's name.
- Organization (`organization`, text): The organization whose workspaces to choose from. Only used to fill the workspace list.
- Workspace (`workspace`, text, required): The workspace it belongs to. Pick one, or use an ID from List workspaces.

**Outputs**

- `data` (object): The tag.

**Example output**

```json
{
  "data": {
    "documentCount": 4,
    "id": 1,
    "name": "Grove Street King",
    "workspace": "mEFayXdO"
  }
}
```

### Create workspace

Create a workspace to hold documents in an organization.

**Inputs**

- Organization (`organization`, text, required): The organization to create it in. Pick one, or use an ID from List organizations.
- Name (`name`, text, required): The workspace's name.
- Who can see it (`visibility`, text): Who can open the workspace. One of: `organization` (Everyone in the organization), `private` (Only people added to it).
- Reject duplicates (`rejectDuplicates`, true/false): Turn on to fail uploads that duplicate an existing document, without using credits.
- Reject wrong types (`rejectInvalidDocuments`, true/false): Turn on to reject documents of the wrong or an unknown type, without using credits.
- Document types (`documentTypes`, list): The IDs of the document types to use in this workspace.

**Outputs**

- `data` (object): The workspace.

**Example output**

```json
{
  "data": {
    "confirmedDocsCount": 12,
    "identifier": "mEFayXdO",
    "ingestEmail": "mefayxdo@ingest.affinda.com",
    "name": "Grove Street King",
    "organization": {
      "identifier": "mEFayXdO",
      "name": "Grove Street King"
    },
    "rejectDuplicates": false,
    "rejectInvalidDocuments": false,
    "unvalidatedDocsCount": 3,
    "visibility": "organization"
  }
}
```

### Delete document

Delete a document and its results.

**Inputs**

- Document (`document_id`, text, required): The document's ID, from Upload document or List documents.

**Outputs**

- `data` (object): Affinda's answer, empty when it worked.

**Example output**

```json
{
  "data": {}
}
```

### Delete tag

Delete a tag.

**Inputs**

- Tag (`tag_id`, number, required): The tag's ID, from List tags or Create tag.

**Outputs**

- `data` (object): Affinda's answer, empty when it worked.

**Example output**

```json
{
  "data": {}
}
```

### Delete workspace

Delete a workspace.

**Inputs**

- Workspace (`workspace_id`, text, required): The workspace's ID, from List workspaces or Create workspace.

**Outputs**

- `data` (object): Affinda's answer, empty when it worked.

**Example output**

```json
{
  "data": {}
}
```

### Get credit usage

See how many credits an organization used each day over a period.

**Inputs**

- Organization (`organization`, text, required): The organization to report on. You must be its admin or owner.
- Workspace (`workspace`, text): Only usage in this workspace.
- Document type (`document_type`, text): Only usage for this document type.
- From (`start`, date): The first day. Defaults to a year before the last day.
- To (`end`, date): The last day. Defaults to today.

**Outputs**

- `data` (object): Daily credit use.

**Example output**

```json
{
  "data": {
    "end": "2025-04-30",
    "items": [
      {
        "count": 123,
        "date": "2025-04-15"
      }
    ],
    "scope": "organization",
    "scopeIdentifier": "mEFayXdO",
    "start": "2025-04-01",
    "total": 4320
  }
}
```

### Get document

Get a document with what Affinda extracted from it.

**Inputs**

- Document (`document_id`, text, required): The document's ID, from Upload document or List documents.
- Compact result (`compact`, true/false): Turn on for a shorter result with only the extracted values.

**Outputs**

- `data` (object): The document.

**Example output**

```json
{
  "data": {
    "data": {},
    "extractor": "resume",
    "meta": {
      "createdDt": "2020-12-10T01:43:30.000000Z",
      "customIdentifier": "46ab8b02-0e5b-420c-877c-8b678d46a834",
      "documentType": "mEFayXdO",
      "failed": false,
      "file": "https://affinda-api.s3.amazonaws.com/media/documents/Document.docx",
      "fileName": "Document.pdf",
      "identifier": "mEFayXdO",
      "isArchived": false,
      "isConfirmed": false,
      "isRejected": false,
      "language": "en",
      "pdf": "https://affinda-api.s3.amazonaws.com/media/documents/Document.pdf",
      "ready": true,
      "readyDt": "2020-12-10T01:43:32.276724Z",
      "reviewUrl": "https://app.affinda.com/validate/mEFayXdO",
      "tags": [
        {
          "documentCount": 4,
          "id": 1,
          "name": "Grove Street King",
          "workspace": "mEFayXdO"
        }
      ],
      "workspace": {
        "identifier": "mEFayXdO",
        "name": "Grove Street King"
      }
    }
  }
}
```

### Get document type

Get one document type.

**Inputs**

- Document type (`document_type_id`, text, required): The document type. Pick one, or use an ID from List document types.

**Outputs**

- `data` (object): The document type.

**Example output**

```json
{
  "data": {
    "description": "Resumes and CVs",
    "identifier": "mEFayXdO",
    "ingest_email": "resumes@ingest.affinda.com",
    "name": "Grove Street King",
    "organization": "mEFayXdO"
  }
}
```

### Get workspace

Get a workspace and its document counts.

**Inputs**

- Workspace (`workspace_id`, text, required): The workspace's ID, from List workspaces or Create workspace.

**Outputs**

- `data` (object): The workspace.

**Example output**

```json
{
  "data": {
    "confirmedDocsCount": 12,
    "identifier": "mEFayXdO",
    "ingestEmail": "mefayxdo@ingest.affinda.com",
    "name": "Grove Street King",
    "organization": {
      "identifier": "mEFayXdO",
      "name": "Grove Street King"
    },
    "rejectDuplicates": false,
    "rejectInvalidDocuments": false,
    "unvalidatedDocsCount": 3,
    "visibility": "organization"
  }
}
```

### List document types

List the document types you can use, such as resumes or invoices.

**Inputs**

- Organization (`organization`, text): Only document types of this organization.
- Workspace (`workspace`, text): Only document types used in this workspace.

**Outputs**

- `data` (list): The document types.

**Example output**

```json
{
  "data": [
    {
      "description": "Resumes and CVs",
      "identifier": "mEFayXdO",
      "ingest_email": "resumes@ingest.affinda.com",
      "name": "Grove Street King",
      "organization": "mEFayXdO"
    }
  ]
}
```

### List documents

List one page of documents, filtered and sorted as you choose.

**Inputs**

- Organization (`organization`, text): The organization whose workspaces to choose from. Only used to fill the workspace list.
- Workspace (`workspace`, text): Only those in this workspace.
- State (`state`, text): Only documents in this state. One of: `uploaded`, `review` (In review), `validated`, `archived`, `rejected`.
- Search (`search`, text): Only documents whose file name, ID or tag name contains this text.
- Tags (`tags`, list): Only documents with these tag IDs.
- Created (`created_dt`, text): Only documents created in this period. One of: `today`, `yesterday`, `week` (This week), `month` (This month), `year` (This year).
- Your ID (`custom_identifier`, text): Only documents with this ID of yours.
- Ready (`ready`, true/false): Only documents that have, or haven't, finished processing.
- Failed (`failed`, true/false): Only documents that have, or haven't, failed.
- Include extracted data (`include_data`, true/false): Turn on to include a summary of what was extracted.
- Order (`ordering`, text): How to sort them. One of: `-created_dt` (Newest first), `created_dt` (Oldest first), `file_name` (File name A to Z), `-file_name` (File name Z to A), `-validated_dt` (Recently validated first), `-archived_dt` (Recently archived first).
- Skip (`offset`, number): How many results to skip, for paging. At least 0.
- Limit (`limit`, number): How many results to return, up to 100. From 1 to 100.

**Outputs**

- `data` (object): One page of documents.

**Example output**

```json
{
  "data": {
    "count": 1,
    "next": "https://api.affinda.com/v3/documents?limit=20&offset=20",
    "previous": "https://api.affinda.com/v3/documents?limit=20&offset=0",
    "results": [
      {
        "data": {},
        "extractor": "resume",
        "meta": {
          "createdDt": "2020-12-10T01:43:30.000000Z",
          "customIdentifier": "46ab8b02-0e5b-420c-877c-8b678d46a834",
          "documentType": "mEFayXdO",
          "failed": false,
          "file": "https://affinda-api.s3.amazonaws.com/media/documents/Document.docx",
          "fileName": "Document.pdf",
          "identifier": "mEFayXdO",
          "isArchived": false,
          "isConfirmed": false,
          "isRejected": false,
          "language": "en",
          "pdf": "https://affinda-api.s3.amazonaws.com/media/documents/Document.pdf",
          "ready": true,
          "readyDt": "2020-12-10T01:43:32.276724Z",
          "reviewUrl": "https://app.affinda.com/validate/mEFayXdO",
          "tags": [
            {
              "documentCount": 4,
              "id": 1,
              "name": "Grove Street King",
              "workspace": "mEFayXdO"
            }
          ],
          "workspace": {
            "identifier": "mEFayXdO",
            "name": "Grove Street King"
          }
        }
      }
    ]
  }
}
```

### List extractors

List the extractors an organization can use, including Affinda's ready-made ones.

**Inputs**

- Organization (`organization`, text, required): The organization. Pick one, or use an ID from List organizations.
- Include ready-made (`include_public_extractors`, true/false): Turn on to include Affinda's ready-made extractors.
- Name (`name`, text): Only extractors with this name.

**Outputs**

- `data` (list): The extractors.

**Example output**

```json
{
  "data": [
    {
      "createdDt": "2020-12-10T01:43:30.000000Z",
      "identifier": "mEFayXdO",
      "isCustom": false,
      "name": "Grove Street King",
      "namePlural": "Resumes",
      "validatable": true
    }
  ]
}
```

### List organizations

List the Affinda organizations you belong to.

**Inputs**: None.

**Outputs**

- `data` (list): The organizations.

**Example output**

```json
{
  "data": [
    {
      "identifier": "mEFayXdO",
      "isTrial": false,
      "name": "Grove Street King",
      "userRole": "admin"
    }
  ]
}
```

### List tags

List the tags in your workspaces.

**Inputs**

- Organization (`organization`, text): The organization whose workspaces to choose from. Only used to fill the workspace list.
- Workspace (`workspace`, text): Only those in this workspace.
- Name (`name`, text): Only tags with this name.
- Skip (`offset`, number): How many results to skip, for paging. At least 0.
- Limit (`limit`, number): How many results to return, up to 100. From 1 to 100.

**Outputs**

- `data` (list): The tags.

**Example output**

```json
{
  "data": [
    {
      "documentCount": 4,
      "id": 1,
      "name": "Grove Street King",
      "workspace": "mEFayXdO"
    }
  ]
}
```

### List validation results

List the results of a document's validation rules.

**Inputs**

- Document (`document`, text, required): The document's ID, from Upload document or List documents.
- Skip (`offset`, number): How many results to skip, for paging. At least 0.
- Limit (`limit`, number): How many results to return, up to 100. From 1 to 100.

**Outputs**

- `data` (list): The validation results.

**Example output**

```json
{
  "data": [
    {
      "annotations": [
        1,
        2,
        3
      ],
      "document": "mEFayXdO",
      "id": 1,
      "message": "Expected a match",
      "passed": true,
      "ruleSlug": "supplier-name-is-alphanumeric"
    }
  ]
}
```

### List workspaces

List the workspaces in an organization.

**Inputs**

- Organization (`organization`, text, required): The organization. Pick one, or use an ID from List organizations.
- Name (`name`, text): Only workspaces with this name.

**Outputs**

- `data` (list): The workspaces.

**Example output**

```json
{
  "data": [
    {
      "confirmedDocsCount": 12,
      "identifier": "mEFayXdO",
      "ingestEmail": "mefayxdo@ingest.affinda.com",
      "name": "Grove Street King",
      "organization": {
        "identifier": "mEFayXdO",
        "name": "Grove Street King"
      },
      "rejectDuplicates": false,
      "rejectInvalidDocuments": false,
      "unvalidatedDocsCount": 3,
      "visibility": "organization"
    }
  ]
}
```

### Remove tag from documents

Take a tag off one or more documents.

**Inputs**

- Tag (`tag`, number, required): The tag's ID, from List tags.
- Documents (`identifiers`, list, required): The IDs of the documents to untag.

**Outputs**

- `data` (object): Affinda's answer, empty when it worked.

**Example output**

```json
{
  "data": {}
}
```

### Update document

Rename, confirm, reject, archive or move a document.

**Inputs**

- Document (`document_id`, text, required): The document's ID, from Upload document or List documents.
- File name (`fileName`, text): The new file name.
- Your ID (`customIdentifier`, text): Your own ID for the document.
- Confirmed (`isConfirmed`, true/false): Turn on to mark the document validated.
- Rejected (`isRejected`, true/false): Turn on to reject the document.
- Archived (`isArchived`, true/false): Turn on to archive the document.
- Organization (`organization`, text): The organization whose workspaces to choose from. Only used to fill the workspace list.
- Workspace (`workspace`, text): Move it to this workspace.
- Document type (`documentType`, text): Change its document type.
- Language (`language`, text): The document's language as a two-letter code.
- Delete at (`expiryTime`, date and time): When Affinda should delete the document.

**Outputs**

- `data` (object): The document.

**Example output**

```json
{
  "data": {
    "data": {},
    "extractor": "resume",
    "meta": {
      "createdDt": "2020-12-10T01:43:30.000000Z",
      "customIdentifier": "46ab8b02-0e5b-420c-877c-8b678d46a834",
      "documentType": "mEFayXdO",
      "failed": false,
      "file": "https://affinda-api.s3.amazonaws.com/media/documents/Document.docx",
      "fileName": "Document.pdf",
      "identifier": "mEFayXdO",
      "isArchived": false,
      "isConfirmed": false,
      "isRejected": false,
      "language": "en",
      "pdf": "https://affinda-api.s3.amazonaws.com/media/documents/Document.pdf",
      "ready": true,
      "readyDt": "2020-12-10T01:43:32.276724Z",
      "reviewUrl": "https://app.affinda.com/validate/mEFayXdO",
      "tags": [
        {
          "documentCount": 4,
          "id": 1,
          "name": "Grove Street King",
          "workspace": "mEFayXdO"
        }
      ],
      "workspace": {
        "identifier": "mEFayXdO",
        "name": "Grove Street King"
      }
    }
  }
}
```

### Update tag

Rename a tag.

**Inputs**

- Tag (`tag_id`, number, required): The tag's ID, from List tags or Create tag.
- Name (`name`, text): The new name.

**Outputs**

- `data` (object): The tag.

**Example output**

```json
{
  "data": {
    "documentCount": 4,
    "id": 1,
    "name": "Grove Street King",
    "workspace": "mEFayXdO"
  }
}
```

### Update workspace

Rename a workspace or change its settings.

**Inputs**

- Workspace (`workspace_id`, text, required): The workspace's ID, from List workspaces or Create workspace.
- Name (`name`, text): The new name.
- Who can see it (`visibility`, text): Who can open the workspace. One of: `organization` (Everyone in the organization), `private` (Only people added to it).
- Reject duplicates (`rejectDuplicates`, true/false): Turn on to fail uploads that duplicate an existing document.
- Reject wrong types (`rejectInvalidDocuments`, true/false): Turn on to reject documents of the wrong or an unknown type.
- Document types (`documentTypes`, list): The IDs of the document types to use in this workspace.

**Outputs**

- `data` (object): The workspace.

**Example output**

```json
{
  "data": {
    "confirmedDocsCount": 12,
    "identifier": "mEFayXdO",
    "ingestEmail": "mefayxdo@ingest.affinda.com",
    "name": "Grove Street King",
    "organization": {
      "identifier": "mEFayXdO",
      "name": "Grove Street King"
    },
    "rejectDuplicates": false,
    "rejectInvalidDocuments": false,
    "unvalidatedDocsCount": 3,
    "visibility": "organization"
  }
}
```

### Upload document

Send a document to Affinda to read, and get back what it extracted.

**Inputs**

- Organization (`organization`, text): The organization whose workspaces to choose from. Only used to fill the workspace list.
- File (`file`, text): The document to upload, such as a PDF, Word file or image. Give this or File URL.
- File URL (`url`, text): A public link to the document. Give this or File.
- Workspace (`workspace`, text, required): The workspace to add it to. Pick one, or use an ID from List workspaces.
- Document type (`documentType`, text): The document type, if you know it. Affinda works it out if left empty.
- Your ID (`customIdentifier`, text): Your own ID for the document. It needn't be unique.
- File name (`fileName`, text): The file's name.
- Language (`language`, text): The document's language as a two-letter code, such as en. Use zh-cn or zh-tw for Chinese.
- Delete at (`expiryTime`, date and time): When Affinda should delete the document. It is kept if left empty.
- Wait for results (`wait`, true/false): Leave on to get the results in this step. Turn off to return at once and fetch them later with Get document.
- Reject duplicates (`rejectDuplicates`, true/false): Turn on to fail if the document duplicates an existing one, without using credits. Uses the workspace's setting if left empty.
- Read as image (`useOcr`, true/false): Turn on to read the text with OCR, off to read it as a PDF. Affinda decides if left empty.
- Low priority (`lowPriority`, true/false): Turn on to mark the document as low priority.
- Compact result (`compact`, true/false): Turn on for a shorter result with only the extracted values.

**Outputs**

- `data` (object): The document.

**Example output**

```json
{
  "data": {
    "data": {},
    "extractor": "resume",
    "meta": {
      "createdDt": "2020-12-10T01:43:30.000000Z",
      "customIdentifier": "46ab8b02-0e5b-420c-877c-8b678d46a834",
      "documentType": "mEFayXdO",
      "failed": false,
      "file": "https://affinda-api.s3.amazonaws.com/media/documents/Document.docx",
      "fileName": "Document.pdf",
      "identifier": "mEFayXdO",
      "isArchived": false,
      "isConfirmed": false,
      "isRejected": false,
      "language": "en",
      "pdf": "https://affinda-api.s3.amazonaws.com/media/documents/Document.pdf",
      "ready": true,
      "readyDt": "2020-12-10T01:43:32.276724Z",
      "reviewUrl": "https://app.affinda.com/validate/mEFayXdO",
      "tags": [
        {
          "documentCount": 4,
          "id": 1,
          "name": "Grove Street King",
          "workspace": "mEFayXdO"
        }
      ],
      "workspace": {
        "identifier": "mEFayXdO",
        "name": "Grove Street King"
      }
    }
  }
}
```
