Poštár

API Documentation

How to Start as SaaS Vendor

  1. Register at https://app.pepposh.eu/register.
  2. Open Settings / API Keys, choose Tenant only and set permissions.
  3. Create participant: POST https://api.pepposh.eu/api/participants?autoregister=true.
  4. Start verification: POST https://api.pepposh.eu/api/participants/{participantId}/verify/initiate?callback=https%3A%2F%2Fyour-saas.example.com%2Fverification%2Fdone. The returned verificationUrl opens the onboarding flow and redirects back to the callback URL when the user finishes or cancels.
  5. Check verification status: GET https://api.pepposh.eu/api/participants/{participantId}/verify/status.
  6. Register in Peppol: POST https://api.pepposh.eu/api/participants/{participantId}/peppol/register. (Tento krok lze přeskočit, pokud jste v prvním kroku použili ?autoregister=true.)
  7. Register webhooks: POST https://api.pepposh.eu/api/participants/{participantId}/webhooks.
  8. Send documents and consume inbox endpoints.

All endpoint examples below use absolute URLs with the production domain.

const CLIENT_ID = process.env.CLIENT_ID!;
const CLIENT_SECRET = process.env.CLIENT_SECRET!;

async function getAccessToken(): Promise<string> {
  const res = await fetch('https://api.pepposh.eu/api/auth/token', {
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    body: new URLSearchParams({
      grant_type: 'client_credentials',
      client_id: CLIENT_ID,
      client_secret: CLIENT_SECRET,
      scope: 'admin',
    }),
  });
  if (!res.ok) throw new Error(`Token error: ${await res.text()}`);
  const { access_token } = await res.json();
  return access_token;
}

const token = await getAccessToken();

const headers = {
  Authorization: `Bearer ${token}`,
  'Content-Type': 'application/json',
};

async function jsonFetch(url: string, init: RequestInit = {}) {
  const res = await fetch(url, {
    ...init,
    headers: { ...headers, ...(init.headers ?? {}) },
  });
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
  return res.json();
}

const participant = await jsonFetch('https://api.pepposh.eu/api/participants?autoregister=true', {
  method: 'POST',
  body: JSON.stringify({
    name: 'Firma s.r.o.',
    registrationNumber: '123',
    vatId: 'CZ123',
    countryCode: 'cz',
  }),
});

const participantId = participant.id; // or 9929:123
const callback = encodeURIComponent('https://your-saas.example.com/verification/done');

const verification = await jsonFetch(
  `https://api.pepposh.eu/api/participants/${participantId}/verify/initiate?callback=${callback}`,
  { method: 'POST' },
);
console.log('Verification URL:', verification.verificationUrl);

const status = await jsonFetch(`https://api.pepposh.eu/api/participants/${participantId}/verify/status`);
console.log('Verification status:', status);

await jsonFetch(`https://api.pepposh.eu/api/participants/${participantId}/peppol/register`, { method: 'POST' });

await jsonFetch(`https://api.pepposh.eu/api/participants/${participantId}/webhooks`, {
  method: 'POST',
  body: JSON.stringify({
    url: 'https://your-saas.example.com/webhooks/peppol',
    events: ['document.received', 'document.status.changed'],
  }),
});

# Send document and wait for processing result. You can repeat this request on error until you get a successful response if processing takes too long.
await jsonFetch(`https://api.pepposh.eu/api/participants/${participantId}/documents/send?wait-for-result`, {
  method: 'PUT',
  body: 'XML PAYLOAD HERE',
});

const inbox = await jsonFetch(`https://api.pepposh.eu/api/participants/${participantId}/documents/inbox`);
for (const doc of inbox.items ?? []) {
  await jsonFetch(`https://api.pepposh.eu/api/documents/${doc.id}/acknowledge`, { method: 'POST' });
}