Integration

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/sdk

Initialization

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'
ParameterTypeDescription
queueKeystringQueue identifier (required)
dataobjectContent to be reviewed (required)
contextobjectBackground info for reviewers
metadataobjectFilterable attributes
summarystringShort 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.

typescript
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);
  }
}