Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

654 B
Raw Blame
import { createAdminClient } from '@spree/admin-sdk'

const client = createAdminClient({
  baseUrl: 'https://your-store.com',
  secretKey: 'sk_xxx',
})

// region:example
const endpoint = await client.webhookEndpoints.create({
  name: 'Order pipeline',
  url: 'https://example.com/webhooks/orders',
  active: true,
  subscriptions: ['order.placed', 'order.canceled'],
})

// The plaintext `secret_key` is returned exactly once on create — persist it
// immediately so you can verify incoming webhook signatures. Subsequent reads
// will return `null`.
const signingSecret = endpoint.secret_key

// endregion:example

export { endpoint, signingSecret }