الانتقال إلى المحتوى الرئيسي

نظرة عامة

Twenty provides both GraphQL and REST APIs for programmatic data import. Use the API when CSV import isn’t practical for your data volume or when you need automated, recurring imports.

When to Use API Import

ScenarioRecommended Method
Under 10,000 recordsCSV Import
10,000 - 50,000 recordsCSV Import (split into files)
50,000+ recordsAPI Import
One-time migrationEither (based on volume)
Recurring importsAPI Import
Real-time syncAPI Import
Integration with other systemsAPI Import
For datasets in the hundreds of thousands, the API is significantly faster and more reliable than multiple CSV imports.

API Rate Limits

Twenty enforces rate limits to ensure system stability:
Limitالقيمة
Requests per minute100
Records per batch call60
Maximum throughput~6,000 records/minute
Plan your import around these limits.For 100,000 records at maximum throughput, expect approximately 17 minutes of import time. Add buffer time for error handling and retries.

البدء

Step 1: Get Your API Key

  1. Go to Settings → Developers
  2. Click + Create API key
  3. Give your key a descriptive name
  4. Copy the API key immediately (it won’t be shown again)
  5. Store it securely
Keep your API key secret.Anyone with your API key can access and modify your workspace data. Never commit it to code repositories or share it publicly.

Step 2: Choose Your API

Twenty supports two API types:
واجهة برمجة التطبيقاتBest Forالتوثيق
GraphQLFlexible queries, fetching related data, complex operationsAPI Docs
RESTSimple CRUD operations, familiar REST patternsAPI Docs
Both APIs support:
  • Creating, reading, updating, and deleting records
  • Batch operations — create or update up to 60 records per call
For imports, use batch operations to maximize throughput within rate limits.

Step 3: Plan Your Import Order

Just like CSV imports, order matters for relations:
  1. Companies first (no dependencies)
  2. People second (can link to Companies)
  3. Opportunities third (can link to Companies and People)
  4. Tasks/Notes (can link to any of the above)
  5. Custom objects (following their dependencies)

أفضل الممارسات

Batch Your Requests

  • Don’t send records one at a time
  • Group up to 60 records per API call
  • This maximizes throughput within rate limits

Handle Rate Limits

  • Implement delays between requests (600ms minimum for sustained imports)
  • Use exponential backoff when you hit limits
  • Monitor for 429 (Too Many Requests) responses

Validate Data First

  • Clean and validate your data before importing
  • Check required fields are populated
  • Verify formats match Twenty’s requirements (see Field Mapping)

Log Everything

  • Log every record imported (including IDs)
  • Log errors with full context
  • This helps debug issues and verify completion

Test First

  • Test with a small batch (10-20 records)
  • Verify data appears correctly in Twenty
  • Then run the full import

Upsert to Avoid Duplicates

The GraphQL API supports batch upsert — update if the record exists, create if not. This prevents duplicates when re-running imports.

Finding Object and Field Names

To see available objects and fields:
  1. Go to Settings → API and Webhooks
  2. Browse the Metadata API
  3. View all standard and custom objects with their fields
The documentation shows all standard and custom objects, their fields, and the expected data types.

Professional Services

For complex API migrations, our partners can help:
ServiceWhat’s Included
Data Model Designdesign your optimal data structure
Migration Scriptswrite and run the import scripts
Data Transformationhandle complex mapping and cleanup
Validation & QAverify the migration is complete
Best for:
  • Migrations of 100,000+ records
  • Complex data transformations
  • Tight timelines
  • Teams without developer resources
Contact us at [email protected] or explore our Implementation Services.

FAQ

GraphQL lets you request exactly the data you need in a single query and is better for complex operations. REST uses standard HTTP methods (GET, POST, PUT, DELETE) and may be more familiar if you’ve worked with traditional APIs.
نعم! Use update mutations (GraphQL) or PUT/PATCH requests (REST) with the record’s id.
Query for existing records first using unique identifiers (email, domain). Update if exists, create if not.
Yes, use delete mutations (GraphQL) or DELETE requests (REST).
Not currently, but both APIs work with any HTTP client in any language.

API Documentation

For full implementation details, code examples, and schema reference: