SDK
TypeScript and Python client libraries for the Datashift API.
The SDK enables developer-enforced review: you define which actions require human review in your code. Use it to add review checkpoints to autonomous agents or backend services.
Developer-Enforced vs Agent-Initiated
With the SDK, you decide which actions require review by adding calls in your code. This differs from MCP where the agent decides when to request review based on its reasoning.
Use Cases
- • Autonomous agents — Enforce review for specific actions (e.g., before deployment, high-value transactions)
- • Backend services — Add approval gates to business logic (e.g., all refunds over $500)
- • Workflow automation — Integrate with n8n, Make, Zapier via REST API
Installation
npm install @datashift/sdkInitialization
Create a client with your API key. Get your key from the Console (Settings → Credentials).
import { Datashift } from '@datashift/sdk';
const datashift = new Datashift({
apiKey: process.env.DATASHIFT_API_KEY,
});Submit a Task
Submit a task for human review. The task is immediately queued and assigned to reviewers.
const task = await datashift.submitTask({
queueKey: 'refund-approvals',
data: {
customer_id: 'cust_123',
order_id: 'order_456',
amount: 150.00,
reason: 'Product defective',
},
summary: 'Refund request for $150.00',
});
console.log('Task ID:', task.id);
console.log('State:', task.state); // 'queued'| Parameter | Type | Description |
|---|---|---|
| queueKey | string | Queue identifier (required) |
| data | object | Content to be reviewed (required) |
| context | object | Background info for reviewers |
| metadata | object | Filterable attributes |
| summary | string | Short description (max 255 chars) |
Get Task Status
Check the current status of a task. For real-time notifications, use webhooks.
const task = await datashift.getTask(taskId);
console.log('State:', task.state);
if (task.state === 'reviewed') {
console.log('Result:', task.reviews[0].result);
}Other Methods
listTasks(options?)
List tasks with optional filters (queueKey, state, limit, offset).
listQueues()
List all queues available to your organization.
getQueue(queueKey)
Get configuration for a specific queue.
Getting Results
There are two ways to get review results:
Webhooks (Recommended)
Configure a webhook endpoint to receive notifications when reviews complete. See Webhooks for setup.
Polling
Call getTask() periodically to check status. Useful for simple integrations or when webhooks aren't available.
Error Handling
The SDK provides typed error classes for common scenarios.
import {
AuthenticationError,
NotFoundError,
ValidationError,
RateLimitError,
} from '@datashift/sdk';
try {
const task = await datashift.submitTask({ ... });
} catch (error) {
if (error instanceof ValidationError) {
console.log('Invalid request:', error.message);
} else if (error instanceof AuthenticationError) {
console.log('Invalid API key');
} else if (error instanceof RateLimitError) {
console.log('Rate limited, retry after:', error.retryAfter);
}
}