Build and test your connector

Creating the connector with the SDK

Scaffold the project and install its dependencies:

zcli connectors:create test-github-connectorcd test-github-connectornpm install

The scaffolded project includes a src/settings.json skeleton for publisher-managed OAuth. If your connector uses publisher-managed OAuth, fill it in as described in Creating settings.json - zcli connectors:bundle copies it into the bundle automatically. If your connector uses any other authentication type, delete the file.

Define the connector in src/index.ts - a manifest, an authentication definition, and one or more actions. This example creates a GitHub connector with a single "Create issue" action. See the Connector SDK quick start for the full project structure, input controls, and the authenticated HTTP client; a complete working example ships with the SDK in examples/open-weather.

import { manifest, action, authentication, HttpError } from '@zendesk/connector-sdk';
const createIssue = action({  name: 'create_issue',  title: 'Create Issue',  description: 'Create an issue in a GitHub repository',  inputs: () => [    {      name: 'repository',      title: 'Repository',      value_type: 'string',      required: true,      control: { type: 'text', min_length: 3, max_length: 200 },      description: 'The repository, e.g. "octocat/hello-world".',    },    {      name: 'title',      title: 'Title',      value_type: 'string',      required: true,      control: { type: 'text', min_length: 1, max_length: 256 },      description: 'The issue title.',    },    {      name: 'body',      title: 'Body',      value_type: 'string',      required: false,      control: { type: 'textarea' },      description: 'The issue body.',    },  ],  output: () => ({    type: 'object',    properties: {      id: { type: 'number' },      html_url: { type: 'string' },    },  }),  execute: ({ inputs, client }) => {    const resp = client.request({      url: `https://api.github.com/repos/${inputs.repository}/issues`,      method: 'POST',      body: JSON.stringify({ title: inputs.title, body: inputs.body }),      headers: {        accept: 'application/vnd.github+json',        'content-type': 'application/json',      },    });    if (!resp.ok) {      throw new HttpError({ status: resp.status, message: `GitHub request failed: ${resp.body}` });    }    return JSON.parse(resp.body);  },});
// `auth` is defined in Defining authentication and actions below.export default manifest({  name: 'test-github-connector',  // fictional tutorial name - pick your own before first submission  title: 'Test GitHub Connector',  description: 'Create GitHub issues from Zendesk workflows',  author: 'Your Name',  default_locale: 'en',  version: '1.0.0',  authentication: auth,  actions: [createIssue],});

For a public connector, keep these publishing rules in mind as you define the manifest:

  • name (3–32 characters, kebab-case) is the connector's permanent public identity. It is bound to your Developer Portal submission at first approval - submit every later version through the same submission. This tutorial uses the fictional test-github-connector; choose your connector's real name before your first submission.
  • version must be greater than the latest approved version on every upload.
  • Author names containing "zendesk" are reserved for Zendesk-published connectors.

Defining authentication and actions

The Connector SDK supports bearer_token, api_key, basic_authentication, and oauth2 authentication - see Authentication in the SDK documentation for the general model and input-field reference. For the publisher-managed OAuth terms used below, see Set up publisher-managed OAuth.

For a publisher-managed OAuth connector:

  • Set authentication.type to 'oauth2' and grant_type to 'authorization_code' or 'client_credentials'. The type and grant must exactly match settings.json.
  • Omit authentication.client - Zendesk provisions the OAuth client from settings.json. Do not embed the client id or client secret in source code.
  • Never put real customer or publisher credentials in an authentication input default.

Example - the GitHub connector's publisher-managed OAuth with the authorization_code grant, registered as described in Registering your OAuth app. The app's client id and secret belong only in settings.json, never here:

import { authentication } from '@zendesk/connector-sdk';
const auth = authentication({  type: 'oauth2',  grant_type: 'authorization_code',  // must match settings.json  allowed_domain: 'api.github.com',});

If the OAuth provider hosts each customer at their own subdomain, declare a per-customer input and allow {{oauth_url_subdomain}} in the settings.json URLs - see Creating settings.json:

const auth = authentication({  type: 'oauth2',  grant_type: 'authorization_code',  inputs: [    {      name: 'shop_name',      title: 'Shop name',      value_type: 'string',      control: { type: 'text', max_length: 64 },      required: true,      description: 'The subdomain of your Example store, e.g. "acme" for acme.example.com.',      // Placeholder only - never a real customer value.    },  ],  allowed_domain: '{{inputs.shop_name}}.example.com',  config: {    oauth_url_subdomain: '{{inputs.shop_name}}',  },});