### Find Many Companies (Bash/cURL) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Example using cURL to retrieve multiple company records from the Twenty CRM API. Supports pagination via 'limit' and 'cursor' parameters. Requires an API key for authorization. ```bash # cURL example to fetch companies curl -X GET "https://your-instance.twenty.com/rest/companies?limit=10" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" # Response: # { # "data": { # "companies": [ # { # "id": "123e4567-e89b-12d3-a456-426614174000", # "name": "Acme Corporation", # "domainName": "acme.com", # "employees": 500, # "createdAt": "2024-01-15T10:30:00.000Z", # "updatedAt": "2024-01-15T10:30:00.000Z" # } # ] # }, # "pageInfo": { # "hasNextPage": true, # "startCursor": "123e4567-e89b-12d3-a456-426614174000", # "endCursor": "223e4567-e89b-12d3-a456-426614174001" # }, # "totalCount": 45 # } ``` -------------------------------- ### Create Company (Bash/cURL) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Example using cURL to create a new company record in Twenty CRM. Requires an API key for authorization and sends company details in the request body as JSON. The response includes the newly created company object. ```bash # cURL example to create a company curl -X POST "https://your-instance.twenty.com/rest/companies" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "name": "Tech Innovations Inc", "domainName": "techinnovations.com", "employees": 250, "linkedinUrl": "https://linkedin.com/company/tech-innovations", "address": "123 Tech Street, Silicon Valley, CA" }' # Response: # { # "data": { # "company": { # "id": "323e4567-e89b-12d3-a456-426614174002", # "name": "Tech Innovations Inc", # "domainName": "techinnovations.com", # "employees": 250, # "linkedinUrl": "https://linkedin.com/company/tech-innovations", # "address": "123 Tech Street, Silicon Valley, CA", # "createdAt": "2024-01-20T14:22:00.000Z", # "updatedAt": "2024-01-20T14:22:00.000Z", # "deletedAt": null # } # } # } ``` -------------------------------- ### Create Note in Twenty CRM (Bash) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt This snippet provides a cURL example for creating a note within Twenty CRM. It requires authentication and a JSON payload including the note's title, body, and author ID. ```bash curl -X POST "https://your-instance.twenty.com/rest/notes" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "title": "Initial Discovery Call", "body": "Client expressed interest in enterprise features. Key requirements: SSO, advanced reporting, and API access. Budget approved for Q2.", "authorId": "823e4567-e89b-12d3-a456-426614174007" }' ``` -------------------------------- ### GET /people Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Retrieve contact persons from Twenty CRM with pagination support. ```APIDOC ## GET /people ### Description Retrieve contact persons from Twenty CRM with pagination support. ### Method GET ### Endpoint /rest/people #### Query Parameters - **limit** (integer) - Optional - The maximum number of people to return. - **depth** (integer) - Optional - Specifies the depth of related data to include (e.g., 1 for company information). ### Request Example ```bash curl -X GET "https://your-instance.twenty.com/rest/people?limit=10&depth=1" -H "Authorization: Bearer your_api_key" -H "Content-Type: application/json" -H "Accept: application/json" ``` ### Response #### Success Response (200) - **data** (object) - Contains the list of people and pagination information. - **people** (array) - A list of person objects. - **id** (string) - The unique identifier for the person. - **firstName** (string) - The first name of the person. - **lastName** (string) - The last name of the person. - **email** (string) - The email address of the person. - **phone** (string) - The phone number of the person. - **city** (string) - The city where the person is located. - **companyId** (string) - The ID of the company the person is associated with. - **createdAt** (string) - The date and time the person was created. - **updatedAt** (string) - The date and time the person was last updated. - **pageInfo** (object) - Pagination details. - **hasNextPage** (boolean) - Indicates if there is a next page of results. - **startCursor** (string) - The cursor for the start of the current page. - **endCursor** (string) - The cursor for the end of the current page. - **totalCount** (integer) - The total number of people available. #### Response Example ```json { "data": { "people": [ { "id": "423e4567-e89b-12d3-a456-426614174003", "firstName": "John", "lastName": "Doe", "email": "john.doe@acme.com", "phone": "+1-555-0123", "city": "San Francisco", "companyId": "123e4567-e89b-12d3-a456-426614174000", "createdAt": "2024-01-16T09:15:00.000Z", "updatedAt": "2024-01-16T09:15:00.000Z" } ] }, "pageInfo": { "hasNextPage": true, "startCursor": "423e4567-e89b-12d3-a456-426614174003", "endCursor": "523e4567-e89b-12d3-a456-426614174004" }, "totalCount": 127 } ``` ``` -------------------------------- ### GET /companies Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Retrieve multiple companies from Twenty CRM with pagination and filtering support. ```APIDOC ## GET /companies ### Description Retrieve multiple companies from Twenty CRM with pagination and filtering support. ### Method GET ### Endpoint /rest/companies #### Query Parameters - **limit** (integer) - Optional - The maximum number of companies to return. ### Request Example ```bash curl -X GET "https://your-instance.twenty.com/rest/companies?limit=10" -H "Authorization: Bearer your_api_key" -H "Content-Type: application/json" -H "Accept: application/json" ``` ### Response #### Success Response (200) - **data** (object) - Contains the list of companies and pagination information. - **companies** (array) - A list of company objects. - **id** (string) - The unique identifier for the company. - **name** (string) - The name of the company. - **domainName** (string) - The domain name of the company. - **employees** (integer) - The number of employees. - **createdAt** (string) - The date and time the company was created. - **updatedAt** (string) - The date and time the company was last updated. - **pageInfo** (object) - Pagination details. - **hasNextPage** (boolean) - Indicates if there is a next page of results. - **startCursor** (string) - The cursor for the start of the current page. - **endCursor** (string) - The cursor for the end of the current page. - **totalCount** (integer) - The total number of companies available. #### Response Example ```json { "data": { "companies": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "Acme Corporation", "domainName": "acme.com", "employees": 500, "createdAt": "2024-01-15T10:30:00.000Z", "updatedAt": "2024-01-15T10:30:00.000Z" } ] }, "pageInfo": { "hasNextPage": true, "startCursor": "123e4567-e89b-12d3-a456-426614174000", "endCursor": "223e4567-e89b-12d3-a456-426614174001" }, "totalCount": 45 } ``` ``` -------------------------------- ### Find Many People (Bash/cURL) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Example using cURL to retrieve a list of people (contacts) from Twenty CRM. It supports pagination with the 'limit' parameter and detailed information retrieval using 'depth'. API key authentication is required. ```bash # cURL example to fetch people curl -X GET "https://your-instance.twenty.com/rest/people?limit=10&depth=1" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" # Response: # { # "data": { # "people": [ # { # "id": "423e4567-e89b-12d3-a456-426614174003", # "firstName": "John", # "lastName": "Doe", # "email": "john.doe@acme.com", # "phone": "+1-555-0123", # "city": "San Francisco", # "companyId": "123e4567-e89b-12d3-a456-426614174000", # "createdAt": "2024-01-16T09:15:00.000Z", # "updatedAt": "2024-01-16T09:15:00.000Z" # } # ] # }, # "pageInfo": { # "hasNextPage": true, # "startCursor": "423e4567-e89b-12d3-a456-426614174003", # "endCursor": "523e4567-e89b-12d3-a456-426614174004" # }, # "totalCount": 127 # } ``` -------------------------------- ### Create Person (Bash/cURL) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Example using cURL to create a new person (contact) record in Twenty CRM. This operation requires an API key for authentication and accepts person details in JSON format in the request body. The response contains the newly created person object. ```bash # cURL example to create a person curl -X POST "https://your-instance.twenty.com/rest/people" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "firstName": "Jane", "lastName": "Smith", "email": "jane.smith@techinnovations.com", "phone": "+1-555-0456", "city": "Austin", "companyId": "323e4567-e89b-12d3-a456-426614174002", "linkedinUrl": "https://linkedin.com/in/janesmith" }' # Response: # { # "data": { # "person": { # "id": "623e4567-e89b-12d3-a456-426614174005", # "firstName": "Jane", ``` -------------------------------- ### POST /people Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Create a new contact person in Twenty CRM. ```APIDOC ## POST /people ### Description Create a new contact person in Twenty CRM. ### Method POST ### Endpoint /rest/people #### Request Body - **firstName** (string) - Required - The first name of the person. - **lastName** (string) - Required - The last name of the person. - **email** (string) - Required - The email address of the person. - **phone** (string) - Optional - The phone number of the person. - **city** (string) - Optional - The city where the person is located. - **companyId** (string) - Optional - The ID of the company the person is associated with. - **linkedinUrl** (string) - Optional - The LinkedIn profile URL of the person. ### Request Example ```bash curl -X POST "https://your-instance.twenty.com/rest/people" -H "Authorization: Bearer your_api_key" -H "Content-Type: application/json" -H "Accept: application/json" -d { "firstName": "Jane", "lastName": "Smith", "email": "jane.smith@techinnovations.com", "phone": "+1-555-0456", "city": "Austin", "companyId": "323e4567-e89b-12d3-a456-426614174002", "linkedinUrl": "https://linkedin.com/in/janesmith" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the created person object. - **person** (object) - The newly created person. - **id** (string) - The unique identifier for the person. - **firstName** (string) - The first name of the person. - **lastName** (string) - The last name of the person. - **email** (string) - The email address of the person. - **phone** (string) - The phone number of the person. - **city** (string) - The city where the person is located. - **companyId** (string) - The ID of the company the person is associated with. - **linkedinUrl** (string) - The LinkedIn profile URL of the person. - **createdAt** (string) - The date and time the person was created. - **updatedAt** (string) - The date and time the person was last updated. #### Response Example ```json { "data": { "person": { "id": "623e4567-e89b-12d3-a456-426614174005", "firstName": "Jane", "lastName": "Smith", "email": "jane.smith@techinnovations.com", "phone": "+1-555-0456", "city": "Austin", "companyId": "323e4567-e89b-12d3-a456-426614174002", "linkedinUrl": "https://linkedin.com/in/janesmith", "createdAt": "2024-01-21T11:05:00.000Z", "updatedAt": "2024-01-21T11:05:00.000Z" } } } ``` ``` -------------------------------- ### POST /companies Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Create a new company record in Twenty CRM. ```APIDOC ## POST /companies ### Description Create a new company record in Twenty CRM. ### Method POST ### Endpoint /rest/companies #### Request Body - **name** (string) - Required - The name of the company. - **domainName** (string) - Required - The domain name of the company. - **employees** (integer) - Optional - The number of employees. - **linkedinUrl** (string) - Optional - The LinkedIn URL of the company. - **address** (string) - Optional - The address of the company. ### Request Example ```bash curl -X POST "https://your-instance.twenty.com/rest/companies" -H "Authorization: Bearer your_api_key" -H "Content-Type: application/json" -H "Accept: application/json" -d { "name": "Tech Innovations Inc", "domainName": "techinnovations.com", "employees": 250, "linkedinUrl": "https://linkedin.com/company/tech-innovations", "address": "123 Tech Street, Silicon Valley, CA" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the created company object. - **company** (object) - The newly created company. - **id** (string) - The unique identifier for the company. - **name** (string) - The name of the company. - **domainName** (string) - The domain name of the company. - **employees** (integer) - The number of employees. - **linkedinUrl** (string) - The LinkedIn URL of the company. - **address** (string) - The address of the company. - **createdAt** (string) - The date and time the company was created. - **updatedAt** (string) - The date and time the company was last updated. - **deletedAt** (string|null) - The date and time the company was deleted, if applicable. #### Response Example ```json { "data": { "company": { "id": "323e4567-e89b-12d3-a456-426614174002", "name": "Tech Innovations Inc", "domainName": "techinnovations.com", "employees": 250, "linkedinUrl": "https://linkedin.com/company/tech-innovations", "address": "123 Tech Street, Silicon Valley, CA", "createdAt": "2024-01-20T14:22:00.000Z", "updatedAt": "2024-01-20T14:22:00.000Z", "deletedAt": null } } } ``` ``` -------------------------------- ### Twenty CRM API Credentials Configuration for n8n Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Sets up credential management for authenticating with the Twenty CRM API. It defines properties for an API key and domain URL, and configures generic authentication using a Bearer token. Includes a test request to verify the credentials. ```typescript import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties, } from 'n8n-workflow'; export class TwentyApi implements ICredentialType { name = 'twentyApi'; displayName = 'Twenty API'; properties: INodeProperties[] = [ { displayName: 'API key', name: 'apiKey', type: 'string', typeOptions: { password: true }, default: '', }, { displayName: 'Domain', name: 'domain', type: 'string', default: '', }, ]; authenticate: IAuthenticateGeneric = { type: 'generic', properties: { headers: { Authorization: '={{"Bearer " + $credentials.apiKey}}', }, }, }; test: ICredentialTestRequest = { request: { baseURL: '={{$credentials?.domain}}', url: '/open-api/core', }, }; } // Usage in n8n: // 1. Generate API key in Twenty: Settings -> Developers -> Create API Key // 2. In n8n, add Twenty API credential with: // - API key: your_generated_api_key // - Domain: https://your-instance.twenty.com (without /rest/ path) ``` -------------------------------- ### POST /rest/opportunities Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Create a new sales opportunity in Twenty CRM. This endpoint allows you to define key details of a potential deal. ```APIDOC ## POST /rest/opportunities ### Description Create a sales opportunity in Twenty CRM. This endpoint allows you to define key details of a potential deal. ### Method POST ### Endpoint https://your-instance.twenty.com/rest/opportunities ### Parameters #### Query Parameters None #### Request Body - **name** (string) - Required - The name of the opportunity. - **amount** (number) - Required - The monetary value of the opportunity. - **stage** (string) - Required - The current stage of the opportunity (e.g., 'proposal'). - **companyId** (string) - Required - The ID of the company associated with this opportunity. - **pointOfContactId** (string) - Optional - The ID of the primary contact for this opportunity. - **closeDate** (string) - Optional - The expected closing date of the opportunity in ISO 8601 format. ### Request Example ```json { "name": "Enterprise Software Deal", "amount": 50000, "stage": "proposal", "companyId": "323e4567-e89b-12d3-a456-426614174002", "pointOfContactId": "623e4567-e89b-12d3-a456-426614174005", "closeDate": "2024-03-31T00:00:00.000Z" } ``` ### Response #### Success Response (200) - **data** (object) - **opportunity** (object) - **id** (string) - The unique identifier for the created opportunity. - **name** (string) - The name of the opportunity. - **amount** (number) - The monetary value of the opportunity. - **stage** (string) - The current stage of the opportunity. - **companyId** (string) - The ID of the associated company. - **pointOfContactId** (string) - The ID of the associated point of contact. - **closeDate** (string) - The expected closing date. - **createdAt** (string) - Timestamp when the opportunity was created. - **updatedAt** (string) - Timestamp when the opportunity was last updated. #### Response Example ```json { "data": { "opportunity": { "id": "723e4567-e89b-12d3-a456-426614174006", "name": "Enterprise Software Deal", "amount": 50000, "stage": "proposal", "companyId": "323e4567-e89b-12d3-a456-426614174002", "pointOfContactId": "623e4567-e89b-12d3-a456-426614174005", "closeDate": "2024-03-31T00:00:00.000Z", "createdAt": "2024-01-22T08:30:00.000Z", "updatedAt": "2024-01-22T08:30:00.000Z" } } } ``` ``` -------------------------------- ### Create Opportunity in Twenty CRM (Bash) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt This snippet demonstrates how to create a new sales opportunity in Twenty CRM using a cURL command. It requires an API key for authentication and a JSON payload with opportunity details. ```bash curl -X POST "https://your-instance.twenty.com/rest/opportunities" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "name": "Enterprise Software Deal", "amount": 50000, "stage": "proposal", "companyId": "323e4567-e89b-12d3-a456-426614174002", "pointOfContactId": "623e4567-e89b-12d3-a456-426614174005", "closeDate": "2024-03-31T00:00:00.000Z" }' ``` -------------------------------- ### Twenty Node Configuration for n8n Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Configures the main n8n node for Twenty CRM integration. It dynamically generates properties from the OpenAPI specification, sets up authentication, and defines request defaults for interacting with the Twenty CRM REST API. ```typescript import { INodeType, INodeTypeDescription } from 'n8n-workflow'; import { N8NPropertiesBuilder, N8NPropertiesBuilderConfig } from '@devlikeapro/n8n-openapi-node'; import * as doc from './twenty-v1.0.3-openapi.json'; const config: N8NPropertiesBuilderConfig = {}; const parser = new N8NPropertiesBuilder(doc, config); const properties = parser.build(); const credentialName = 'twentyApi'; export class Twenty implements INodeType { description: INodeTypeDescription = { displayName: 'TwentyDEV', name: 'twenty', icon: 'file:twenty.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Consume the Twenty API', defaults: { name: 'Twenty', }, inputs: ['main'], outputs: ['main'], credentials: [ { name: credentialName, required: true, }, ], requestDefaults: { headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, baseURL: '={{$credentials.domain}}', }, properties: properties, }; } ``` -------------------------------- ### Create Company and Contact in Twenty CRM using n8n Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt This JSON configures an n8n workflow to create a new company and then a contact person associated with that company in Twenty CRM. It uses n8n's expression system to dynamically set company and contact details from incoming JSON data and links the contact to the newly created company. ```json { "nodes": [ { "parameters": { "resource": "companies", "operation": "create", "name": "={{ $json.companyName }}", "domainName": "={{ $json.domain }}", "employees": "={{ $json.employeeCount }}" }, "name": "Create Company in Twenty", "type": "n8n-nodes-twenty.twenty", "position": [500, 300], "credentials": { "twentyApi": { "id": "1", "name": "Twenty CRM Account" } } }, { "parameters": { "resource": "people", "operation": "create", "firstName": "={{ $json.firstName }}", "lastName": "={{ $json.lastName }}", "email": "={{ $json.email }}", "companyId": "={{ $node['Create Company in Twenty'].json.data.company.id }}" }, "name": "Create Contact Person", "type": "n8n-nodes-twenty.twenty", "position": [700, 300], "credentials": { "twentyApi": { "id": "1", "name": "Twenty CRM Account" } } } ], "connections": { "Create Company in Twenty": { "main": [ [ { "node": "Create Contact Person", "type": "main", "index": 0 } ] ] } } } ``` -------------------------------- ### Create Task in Twenty CRM (Bash) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt This snippet shows how to create a new task in Twenty CRM using cURL. It requires authentication and a JSON payload specifying the task's title, due date, status, and assignee. ```bash curl -X POST "https://your-instance.twenty.com/rest/tasks" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "title": "Follow up on proposal", "body": "Send follow-up email with pricing details", "dueAt": "2024-01-25T17:00:00.000Z", "status": "TODO", "assigneeId": "823e4567-e89b-12d3-a456-426614174007" }' ``` -------------------------------- ### POST /rest/notes Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Add a note to a company, person, or opportunity in Twenty CRM. Notes provide additional context and details. ```APIDOC ## POST /rest/notes ### Description Add a note to a company, person, or opportunity in Twenty CRM. Notes provide additional context and details. ### Method POST ### Endpoint https://your-instance.twenty.com/rest/notes ### Parameters #### Query Parameters None #### Request Body - **title** (string) - Required - The title of the note. - **body** (string) - Required - The content of the note. - **authorId** (string) - Optional - The ID of the user who authored the note. ### Request Example ```json { "title": "Initial Discovery Call", "body": "Client expressed interest in enterprise features. Key requirements: SSO, advanced reporting, and API access. Budget approved for Q2.", "authorId": "823e4567-e89b-12d3-a456-426614174007" } ``` ### Response #### Success Response (200) - **data** (object) - **note** (object) - **id** (string) - The unique identifier for the created note. - **title** (string) - The title of the note. - **body** (string) - The content of the note. - **authorId** (string) - The ID of the author. - **createdAt** (string) - Timestamp when the note was created. - **updatedAt** (string) - Timestamp when the note was last updated. #### Response Example ```json { "data": { "note": { "id": "a23e4567-e89b-12d3-a456-426614174009", "title": "Initial Discovery Call", "body": "Client expressed interest in enterprise features. Key requirements: SSO, advanced reporting, and API access. Budget approved for Q2.", "authorId": "823e4567-e89b-12d3-a456-426614174007", "createdAt": "2024-01-22T10:00:00.000Z", "updatedAt": "2024-01-22T10:00:00.000Z" } } } ``` ``` -------------------------------- ### POST /rest/tasks Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Create a new task associated with a record in Twenty CRM. Tasks can be used for follow-ups and managing to-dos. ```APIDOC ## POST /rest/tasks ### Description Create a task associated with a record in Twenty CRM. Tasks can be used for follow-ups and managing to-dos. ### Method POST ### Endpoint https://your-instance.twenty.com/rest/tasks ### Parameters #### Query Parameters None #### Request Body - **title** (string) - Required - The title of the task. - **body** (string) - Optional - A detailed description of the task. - **dueAt** (string) - Optional - The due date and time for the task in ISO 8601 format. - **status** (string) - Optional - The current status of the task (e.g., 'TODO', 'IN_PROGRESS', 'DONE'). - **assigneeId** (string) - Optional - The ID of the user assigned to this task. ### Request Example ```json { "title": "Follow up on proposal", "body": "Send follow-up email with pricing details", "dueAt": "2024-01-25T17:00:00.000Z", "status": "TODO", "assigneeId": "823e4567-e89b-12d3-a456-426614174007" } ``` ### Response #### Success Response (200) - **data** (object) - **task** (object) - **id** (string) - The unique identifier for the created task. - **title** (string) - The title of the task. - **body** (string) - The description of the task. - **dueAt** (string) - The due date and time. - **status** (string) - The status of the task. - **assigneeId** (string) - The ID of the assigned user. - **createdAt** (string) - Timestamp when the task was created. - **updatedAt** (string) - Timestamp when the task was last updated. #### Response Example ```json { "data": { "task": { "id": "923e4567-e89b-12d3-a456-426614174008", "title": "Follow up on proposal", "body": "Send follow-up email with pricing details", "dueAt": "2024-01-25T17:00:00.000Z", "status": "TODO", "assigneeId": "823e4567-e89b-12d3-a456-426614174007", "createdAt": "2024-01-22T09:15:00.000Z", "updatedAt": "2024-01-22T09:15:00.000Z" } } } ``` ``` -------------------------------- ### Twenty API Request Helper (TypeScript) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt A generic TypeScript function for making authenticated requests to the Twenty API. It handles credentials, request options, and error handling using n8n-workflow utilities. This function is designed to be used within n8n node executions. ```typescript import { IDataObject, IExecuteFunctions, IRequestOptions, IHttpRequestMethods, NodeApiError, NodeOperationError, } from 'n8n-workflow'; export async function twentyApiRequest( this: IExecuteFunctions, method: IHttpRequestMethods, endpoint: string, body: IDataObject = {}, qs: IDataObject = {}, path: string = '/rest', ) { const credentials = await this.getCredentials('twentyApi'); if (credentials === undefined) { throw new NodeOperationError(this.getNode(), 'No credentials returned!'); } const options: IRequestOptions = { method, body, qs, uri: `${credentials.domain}${path}${endpoint}`, json: true, }; if (!Object.keys(body).length) { delete options.body; } if (!Object.keys(qs).length) { delete options.qs; } try { return await this.helpers.requestWithAuthentication.call(this, 'twentyApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } } // Example usage within a node execution: // const response = await twentyApiRequest.call( // this, // 'POST', // '/companies', // { // name: 'Acme Corporation', // domainName: 'acme.com', // employees: 500 // } // ); ``` -------------------------------- ### PATCH /rest/companies/{id} Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Update an existing company record by its ID. This allows for partial updates to company details. ```APIDOC ## PATCH /rest/companies/{id} ### Description Update an existing company record by ID. This allows for partial updates to company details. ### Method PATCH ### Endpoint https://your-instance.twenty.com/rest/companies/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the company to update. #### Query Parameters None #### Request Body - **employees** (number) - Optional - The number of employees at the company. - **address** (string) - Optional - The physical address of the company. ### Request Example ```json { "employees": 300, "address": "456 Innovation Blvd, Austin, TX" } ``` ### Response #### Success Response (200) - **data** (object) - **company** (object) - **id** (string) - The ID of the updated company. - **name** (string) - The name of the company. - **domainName** (string) - The domain name of the company. - **employees** (number) - The updated number of employees. - **address** (string) - The updated address. - **updatedAt** (string) - Timestamp when the company was last updated. #### Response Example ```json { "data": { "company": { "id": "323e4567-e89b-12d3-a456-426614174002", "name": "Tech Innovations Inc", "domainName": "techinnovations.com", "employees": 300, "address": "456 Innovation Blvd, Austin, TX", "updatedAt": "2024-01-23T13:20:00.000Z" } } } ``` ``` -------------------------------- ### DELETE /rest/{resource}/{id} Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt Delete a record by specifying the resource type and its ID. This is a generic endpoint for deleting various record types. ```APIDOC ## DELETE /rest/{resource}/{id} ### Description Delete a record by resource type and ID. This is a generic endpoint for deleting various record types. ### Method DELETE ### Endpoint https://your-instance.twenty.com/rest/{resource}/{id} ### Parameters #### Path Parameters - **resource** (string) - Required - The type of resource to delete (e.g., 'companies', 'contacts', 'opportunities'). - **id** (string) - Required - The unique identifier of the record to delete. #### Query Parameters None ### Request Example ```bash # cURL example to delete a company curl -X DELETE "https://your-instance.twenty.com/rest/companies/323e4567-e89b-12d3-a456-426614174002" \ -H "Authorization: Bearer your_api_key" \ -H "Accept: application/json" ``` ### Response #### Success Response (200) - **data** (object) - **{resource}** (object) - **id** (string) - The ID of the deleted record. - **deletedAt** (string) - Timestamp indicating when the record was deleted. #### Response Example ```json { "data": { "company": { "id": "323e4567-e89b-12d3-a456-426614174002", "deletedAt": "2024-01-24T09:30:00.000Z" } } } ``` ``` -------------------------------- ### Update Company in Twenty CRM (Bash) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt This snippet demonstrates updating an existing company record in Twenty CRM using a cURL PATCH request. It requires authentication and a JSON payload with the fields to be updated, identified by the company ID. ```bash curl -X PATCH "https://your-instance.twenty.com/rest/companies/323e4567-e89b-12d3-a456-426614174002" \ -H "Authorization: Bearer your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "employees": 300, "address": "456 Innovation Blvd, Austin, TX" }' ``` -------------------------------- ### Delete Record in Twenty CRM (Bash) Source: https://context7.com/shodgson/n8n-nodes-twenty/llms.txt This snippet shows how to delete a record (e.g., a company) from Twenty CRM using a cURL DELETE request. It requires authentication and the ID of the record to be deleted. ```bash curl -X DELETE "https://your-instance.twenty.com/rest/companies/323e4567-e89b-12d3-a456-426614174002" \ -H "Authorization: Bearer your_api_key" \ -H "Accept: application/json" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.