Skip to content

The SDK

The Git API from code, and webhook verification, with @sypnia/git.

Applies to EngineCloud
View as Markdown
Terminal
npm install @sypnia/git
TypeScript
import { createClient } from '@sypnia/git/client';

const git = createClient({ token: process.env.SYPNIA_TOKEN });

const pr = await git.pulls.create('laespiga/web', {
  head: 'cancel-order', base: 'main',
  title: 'Customers can cancel until 10 am',
  body: 'Case: cancel-order',
});
await git.statuses.create('laespiga/web', pr.headSha, { state: 'success', context: 'ci/tests' });
TypeScript
import { verifyWebhook } from '@sypnia/git/webhooks';

const event = verifyWebhook(rawBody, headers, process.env.WEBHOOK_SECRET!);
if (event.type === 'pull_request' && event.action === 'closed' && event.pull_request.merged) {
  // …
}

Every method maps to one endpoint of the API.

    Search pages, sections and terms