Affinda

Learn how to use Affinda with Composio

Overview

SLUG: AFFINDA

Description

Affinda provides an AI-powered document processing platform that automates data extraction from various document types.

Authentication Details

generic_api_key
stringRequired
workspace_id
stringRequired

Connecting to Affinda

Create an auth config

Use the dashboard to create an auth config for the Affinda toolkit. This allows you to connect multiple Affinda accounts to Composio for agents to use.

1

Select App

Navigate to the Affinda toolkit page and click “Setup Integration”.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Integration”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using API Key

1from composio import Composio
2from composio.types import auth_scheme
3
4# Replace these with your actual values
5affinda_auth_config_id = "ac_YOUR_AFFINDA_CONFIG_ID" # Auth config ID created above
6user_id = "0000-0000-0000" # UUID from database/app
7
8composio = Composio()
9
10def authenticate_toolkit(user_id: str, auth_config_id: str):
11 # Replace this with a method to retrieve an API key from the user.
12 # Or supply your own.
13 user_api_key = input("[!] Enter API key")
14
15 connection_request = composio.connected_accounts.initiate(
16 user_id=user_id,
17 auth_config_id=auth_config_id,
18 config={"auth_scheme": "API_KEY", "val": user_api_key}
19 )
20
21 # API Key authentication is immediate - no redirect needed
22 print(f"Successfully connected Affinda for user {user_id}")
23 print(f"Connection status: {connection_request.status}")
24
25 return connection_request.id
26
27
28connection_id = authenticate_toolkit(user_id, affinda_auth_config_id)
29
30# You can verify the connection using:
31connected_account = composio.connected_accounts.get(connection_id)
32print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Affinda toolkit’s playground

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["AFFINDA"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Create Collection

Description

Tool to create a new collection. use after you have a valid workspace id and want to group documents by a specific extractor within that workspace.

Action Parameters

extractor
stringRequired
name
stringRequired
workspace
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Document

Description

Tool to upload a new document for parsing. use when you have the document file or a public url and need to extract structured data immediately.

Action Parameters

additionalExtractions
object
collection
string
expiryTime
string
file
string
fileName
string
identifier
string
url
string
workspace
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Organization

Description

Tool to create a new organization. use when you have a unique organization name and want to group resources under it.

Action Parameters

name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Workspace

Description

Tool to create a new workspace. use when you need to programmatically create a workspace container within an organization.

Action Parameters

name
stringRequired
organization
stringRequired
reject_invalid_documents
boolean
visibility
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Collection

Description

Tool to delete a specific collection by its id. use when you need to remove an unused collection. use after verifying the collection id.

Action Parameters

collection_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Document

Description

Tool to delete a specific document by its id. use when you need to remove a document that is incorrect or no longer needed, after confirming the document id.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Organization

Description

Tool to delete a specific organization by its id. use when you need to remove an organization after confirming its identifier.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Workspace

Description

Tool to delete a specific workspace by its id. use when you need to remove an unused workspace after confirming the workspace id.

Action Parameters

workspace_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Workspace Membership

Description

Tool to remove a user from a workspace by membership id. use after confirming the workspace membership id to revoke access.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Workspace Memberships

Description

Tool to list all workspace memberships for the authenticated user. use when you need to see roles and access across all workspaces.

Action Parameters

limit
integer
offset
integer
user
string
workspace
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Collection

Description

Tool to retrieve details of a specific collection by its id. use when you need full metadata about a collection after confirming its identifier.

Action Parameters

collection_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Collections

Description

Tool to retrieve a list of all collections. use when you need to list collections in your affinda workspace after authentication.

Action Parameters

limit
integer
offset
integer
workspace
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Document

Description

Tool to retrieve details of a specific document by its id. use when you need full metadata and parsing results for a document after upload.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Documents

Description

Tool to retrieve a list of all documents. use when you need to list documents in your affinda workspace after authentication.

Action Parameters

collection
string
limit
integer
offset
integer
workspace
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Organization

Description

Tool to retrieve details of a specific organization by its id. use when you need to fetch an organization's metadata after confirming its identifier.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Organizations

Description

Tool to retrieve a list of all organizations. use after authenticating to list all organizations available to the api key.

Action Parameters

limit
integer
offset
integer

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Workspace

Description

Tool to retrieve details of a specific workspace by its id. use when you need full workspace metadata after confirming its identifier.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Workspaces

Description

Tool to retrieve a list of all workspaces. use when you need to list workspaces filtered by organization and optional name.

Action Parameters

name
string
organization
stringRequired

Action Response

data
arrayRequired
error
string
successful
booleanRequired

Tool Name: Get Workspace Membership

Description

Tool to retrieve details of a specific workspace membership by its id. use when you need to confirm a user's role and details within a workspace after obtaining the membership identifier.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Collection

Description

Tool to update specific fields of a collection. use when you need to rename or reassign a collection after creation.

Action Parameters

custom_fields
array
documents
array
identifier
stringRequired
name
string
workspace
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Document

Description

Tool to update specific fields of a document. use when you need to rename, reassign, or adjust expiry and storage settings after document creation.

Action Parameters

collection
string
customIdentifier
string
deleteAfterParse
boolean
enableValidationTool
boolean
expiryTime
string
fileName
string
identifier
stringRequired
language
string
regionBias
object
workspace
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Workspace

Description

Tool to update specific fields of a workspace. use when you need to modify a workspace’s name, visibility, or document rejection policy after creation.

Action Parameters

name
string
reject_invalid_documents
boolean
visibility
string
workspace_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Batch Update Annotations

Description

Tool to update multiple annotations in one request. use when you need to modify parsed values or other fields across many annotations at once.

Action Parameters

annotations
arrayRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create RESTHook Subscription

Description

Tool to create a new resthook subscription. use after confirming your webhook endpoint is ready to receive document event notifications.

Action Parameters

event
stringRequired
organization
stringRequired
targetUrl
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Tag

Description

Tool to create a new tag. use when you need to label documents in a specific workspace.

Action Parameters

name
stringRequired
workspace
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Validation Result

Description

Tool to create a validation result. use when recording validation outcomes for a document after parsing.

Action Parameters

annotations
arrayRequired
document
stringRequired
message
stringRequired
passed
boolean
ruleSlug
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Resthook Subscription

Description

Tool to delete a specific resthook subscription by id. use after confirming the subscription identifier when the webhook is no longer needed.

Action Parameters

identifier
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Tags

Description

Tool to list all tags. use after confirming authentication to fetch tags across workspaces.

Action Parameters

limit
integer
name
string
offset
integer
workspace
string

Action Response

data
arrayRequired
error
string
successful
booleanRequired

Tool Name: Get All Validation Results

Description

Tool to list validation results for documents. use after processing documents to inspect validation outcomes.

Action Parameters

document
stringRequired
limit
integer
offset
integer
ordering
string
workspace
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Annotations

Description

Tool to retrieve a list of all annotations. use after parsing documents to list their annotations.

Action Parameters

after
string
before
string
document
string
limit
integer
offset
integer
workspace
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Document Type

Description

Tool to retrieve details of a specific document type by its id. use when you need to confirm the configuration or metadata of a document type before processing documents.

Action Parameters

identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Document Types

Description

Tool to retrieve a list of all document types. use when you need to display or filter documents by type before processing.

Action Parameters

limit
integer
offset
integer
ordering
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Extractors

Description

Tool to retrieve a list of all extractors. use when you need to paginate through available extractors.

Action Parameters

limit
integer
offset
integer
organization
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Resthook Subscription

Description

Tool to retrieve details of a specific resthook subscription by its id. use after confirming its creation to verify its settings.

Action Parameters

identifier
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get RESTHook Subscriptions

Description

Tool to retrieve a list of all resthook subscriptions. use after authenticating to list all webhook subscriptions associated with your account.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Usage by Workspace

Description

Tool to retrieve monthly credits consumption for a workspace. use when tracking usage over a specific period before reporting.

Action Parameters

end
string
start
string
workspace_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Document Data

Description

Tool to update parsed data for a resume or job description document. use after retrieving the document when you want to correct or add parsed fields.

Action Parameters

data
objectRequired
identifier
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Organization

Description

Tool to update specific fields of an organization. use when you need to modify an organization's name, avatar, or webhook and validation settings after creation.

Action Parameters

avatar
string
identifier
stringRequired
name
string
resthook_signature_key
string
validation_tool_config
object

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update RESTHook Subscription

Description

Tool to update an existing resthook subscription. use after confirming the subscription identifier to modify its url, event, or activation status.

Action Parameters

active
boolean
event
string
identifier
integerRequired
targetUrl
string

Action Response

data
objectRequired
error
string
successful
booleanRequired