Browse documentation

On this page

Paprel SDKs and Client Libraries

Paprel is a modular developer stack that deploys in days: a REST API, SDKs, Embedded UI, webhooks and MCP. Use one layer or combine them. Every layer runs on the same tenant-scoped auth model and the same ledger:

LayerWhat it does
REST APICall Paprel from any HTTP client: 323 JSON operations described by an OpenAPI 3.1 spec.
SDKsPost journals, invoices and payments from your backend with typed clients generated from the spec for TypeScript, Python, Go, Java, PHP and more.
Embedded UIShow accounting screens and reports inside your product with the @paprel/embed-* npm packages: Web Components plus a typed headless client.
WebhooksReact to accounting events without polling, through signed webhook delivery.
MCPLet AI agents read the books and draft entries for review through the Paprel MCP server.

Paprel is spec-first, so no language is left waiting for its own SDK. The OpenAPI 3.1 spec defines all 323 operations, each with an operationId and full request and response schemas. Any language with an OpenAPI generator gets a complete, typed client for every operation. When an endpoint ships, it reaches your language the next time you regenerate.

Embedded UI: @paprel/embed-* packages

Paprel publishes Embedded UI on npm as framework-neutral Web Components plus a typed headless client:

PackageWhat it gives you
@paprel/embed-coreAuth contract, token refresh, API transport
@paprel/embed-accountingChart of accounts, journal list, detail and editor, account select, banking and reconciliation components, plus a headless createAccountingClient
@paprel/embed-reportsTrial balance, income statement, balance sheet and other report components

The current release is 0.1.0-beta.1. It is a prerelease, so pin exact versions:

Shell
npm install --save-exact @paprel/embed-core@0.1.0-beta.1 @paprel/embed-accounting@0.1.0-beta.1 @paprel/embed-reports@0.1.0-beta.1

Configure it once at app boot, then mount components anywhere:

TypeScript
import { configureAccounting } from "@paprel/embed-accounting";

configureAccounting({
  baseUrl: "https://api-sandbox.paprel.com",
  auth: {
    partnerDomain: "app.yourproduct.com",
    async getTokens() {
      // Your backend exchanges client credentials and returns a short-lived token.
      const res = await fetch("/api/embed-token", { credentials: "include" });
      return res.json(); // { accessToken, expiresAt, permissions, companyId }
    },
  },
});

import "@paprel/embed-accounting";
import "@paprel/embed-reports";
HTML
<paprel-journal-list page="1"></paprel-journal-list>
<paprel-trial-balance as-of-date="2026-11-20" currency="USD"></paprel-trial-balance>

You can skip the UI and call the API through the same auth:

TypeScript
import { createAccountingClient } from "@paprel/embed-accounting";

const client = createAccountingClient({ baseUrl, auth });
const journals = await client.journals.list({ page: 1 });

Next: Get started with Embedded UI ยท Build the token backend (BFF) ยท Sample app ยท Source on GitHub

Server-side clients generated from OpenAPI

Generate a typed client from the OpenAPI spec in your language, then call Paprel through its typed methods:

LanguageGeneratorYou get
TypeScript / Node.jsopenapi-typescript + openapi-fetchTypes for every path, plus a ~6 kB fetch wrapper
Pythonopenapi-python-clientAn installable package with sync and async functions
Gooapi-codegenOne file with models and a typed client
Java / KotlinOpenAPI Generator (native)A Gradle or Maven project on java.net.http
PHPOpenAPI Generator (php)A Composer package on Guzzle

Each sample gets an access token, lists the chart of accounts and posts a balanced journal. We ran every generator against the live spec (OpenAPI 3.1.0, Paprel Public API 1.1.0) on November 20, 2026. Each sample compiled or type-checked, and its token exchange ran against the sandbox. To run them yourself, see Running the samples.

TypeScript / Node.js

Generator: openapi-typescript with openapi-fetch. It generates types only, so there is no runtime code to vendor.

Shell
npm i openapi-fetch
npm i -D openapi-typescript typescript
npx openapi-typescript https://paprel.com/openapi.json -o src/paprel/schema.d.ts
TypeScript
import createClient, { type Middleware } from "openapi-fetch";
import type { paths } from "./paprel/schema.js";

const baseUrl = "https://api-sandbox.paprel.com";
const header = { "x-partner-domain": "sandbox.paprel.com" };

// 1. Exchange client credentials for a short-lived token, cached until a minute before expiry.
let cached: { token: string; expiresAt: number } | undefined;
async function accessToken(): Promise<string> {
  if (cached && Date.now() < cached.expiresAt) return cached.token;
  const { data, error } = await createClient<paths>({ baseUrl }).POST("/v1/app-connect/oauth/token", {
    headers: header,
    body: {
      grant_type: "client_credentials",
      client_id: process.env.APP_CONNECT_CLIENT_ID!,
      client_secret: process.env.APP_CONNECT_CLIENT_SECRET!,
    },
  });
  if (!data) throw new Error(`Token exchange failed: ${JSON.stringify(error)}`);
  cached = { token: data.access_token, expiresAt: Date.now() + (data.expires_in - 60) * 1000 };
  return cached.token;
}

const auth: Middleware = {
  async onRequest({ request }) {
    request.headers.set("authorization", `Bearer ${await accessToken()}`);
    return request;
  },
};
const paprel = createClient<paths>({ baseUrl });
paprel.use(auth);

// 2. List the chart of accounts.
const accounts = await paprel.GET("/v1/accounting/accounts", { params: { header } });
for (const a of accounts.data?.data ?? []) console.log(a.id, a.account);

// 3. Post a balanced journal.
const { data, error } = await paprel.POST("/v1/accounting/journals", {
  params: { header },
  body: {
    currency: "USD",
    date: new Date().toISOString().slice(0, 10),
    description: "First journal",
    lines: [
      { account_id: process.env.CASH_ACCOUNT_ID!, description: "Cash received", debit: "100.00" },
      { account_id: process.env.REVENUE_ACCOUNT_ID!, description: "Revenue earned", credit: "100.00" },
    ],
    posted: true,
  },
});
if (error) throw new Error(JSON.stringify(error));
console.log(data?.data?.journal?.anchor_id);

To add pagination helpers and a CI check that catches breaking spec changes, see how to generate and maintain an SDK from OpenAPI.

Python

Generator: openapi-python-client. It produces an installable package with typed attrs models and sync and async functions. Use Python 3.11 or later.

Shell
pip install openapi-python-client
openapi-python-client generate --url https://paprel.com/openapi.json
pip install ./paprel-public-api-client

The generator prints a few warnings about schemas it cannot model. They do not affect the operations below.

python
import os
from datetime import date

from paprel_public_api_client import AuthenticatedClient, Client
from paprel_public_api_client.api.accounting_accounts import get_accounts
from paprel_public_api_client.api.accounting_journals import add_journal
from paprel_public_api_client.api.app_connect import oauth_token_exchange
from paprel_public_api_client.models import (
    AppConnectTokenModel,
    BankingAccountListResponse,
    BankingJournalFormModel,
    BankingJournalFormResponse,
    OauthTokenExchangeBody,
)

BASE_URL = "https://api-sandbox.paprel.com"
PARTNER_DOMAIN = "sandbox.paprel.com"

# 1. Exchange client credentials for a short-lived access token.
res = oauth_token_exchange.sync_detailed(
    client=Client(base_url=BASE_URL),
    x_partner_domain=PARTNER_DOMAIN,
    body=OauthTokenExchangeBody.from_dict({
        "grant_type": "client_credentials",
        "client_id": os.environ["APP_CONNECT_CLIENT_ID"],
        "client_secret": os.environ["APP_CONNECT_CLIENT_SECRET"],
    }),
)
token = res.parsed
if not isinstance(token, AppConnectTokenModel):
    raise SystemExit(f"Token exchange failed: {res.status_code} {res.content.decode()}")

paprel = AuthenticatedClient(base_url=BASE_URL, token=token.access_token)

# 2. List the chart of accounts.
accounts = get_accounts.sync(client=paprel, x_partner_domain=PARTNER_DOMAIN)
if isinstance(accounts, BankingAccountListResponse) and accounts.data:
    for account in accounts.data:
        print(account.id, account.account)

# 3. Post a balanced journal.
journal = add_journal.sync(
    client=paprel,
    x_partner_domain=PARTNER_DOMAIN,
    body=BankingJournalFormModel.from_dict({
        "currency": "USD",
        "date": date.today().isoformat(),
        "description": "First journal",
        "lines": [
            {"account_id": os.environ["CASH_ACCOUNT_ID"], "description": "Cash received", "debit": "100.00"},
            {"account_id": os.environ["REVENUE_ACCOUNT_ID"], "description": "Revenue earned", "credit": "100.00"},
        ],
        "posted": True,
    }),
)
if not isinstance(journal, BankingJournalFormResponse) or not journal.data:
    raise SystemExit(f"Journal rejected: {journal}")
print(journal.data.journal.anchor_id)

Every operation also has asyncio and asyncio_detailed variants for async code.

Go

Generator: oapi-codegen v2. It produces a single file with models and a typed client. Go 1.24 or later can pin it as a module tool.

Shell
go get -tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
mkdir -p paprel

Create paprel/oapi-codegen.yaml:

YAML
package: paprel
output: paprel/paprel.gen.go
generate:
  models: true
  client: true
output-options:
  # A few spec schemas end in "Response"; this suffix keeps them from
  # colliding with oapi-codegen's generated response wrappers.
  response-type-suffix: Result
Shell
go tool oapi-codegen -config paprel/oapi-codegen.yaml https://paprel.com/openapi.json
go mod tidy
go
package main

import (
    "context"
    "fmt"
    "log"
    "net/http"
    "os"
    "time"

    "example.com/yourapp/paprel"
)

const (
    baseURL       = "https://api-sandbox.paprel.com"
    partnerDomain = "sandbox.paprel.com"
)

func main() {
    ctx := context.Background()

    // 1. Exchange client credentials for a short-lived access token.
    anon, err := paprel.NewClientWithResponses(baseURL)
    if err != nil {
        log.Fatal(err)
    }
    domain := partnerDomain
    tok, err := anon.OauthTokenExchangeWithResponse(ctx,
        &paprel.OauthTokenExchangeParams{XPartnerDomain: &domain},
        paprel.OauthTokenExchangeJSONRequestBody{
            GrantType:    paprel.ClientCredentials,
            ClientId:     os.Getenv("APP_CONNECT_CLIENT_ID"),
            ClientSecret: os.Getenv("APP_CONNECT_CLIENT_SECRET"),
        })
    if err != nil {
        log.Fatal(err)
    }
    if tok.JSON200 == nil {
        log.Fatalf("token exchange failed: %d %s", tok.StatusCode(), tok.Body)
    }

    // Every later request carries the bearer token.
    client, err := paprel.NewClientWithResponses(baseURL,
        paprel.WithRequestEditorFn(func(_ context.Context, req *http.Request) error {
            req.Header.Set("Authorization", "Bearer "+tok.JSON200.AccessToken)
            return nil
        }))
    if err != nil {
        log.Fatal(err)
    }

    // 2. List the chart of accounts.
    accounts, err := client.GetAccountsWithResponse(ctx, &paprel.GetAccountsParams{XPartnerDomain: partnerDomain})
    if err != nil {
        log.Fatal(err)
    }
    if accounts.JSON200 != nil && accounts.JSON200.Data != nil {
        for _, a := range *accounts.JSON200.Data {
            fmt.Println(a.Id, a.AccountCode)
        }
    }

    // 3. Post a balanced journal.
    debit, credit, posted := "100.00", "100.00", true
    journal, err := client.AddJournalWithResponse(ctx,
        &paprel.AddJournalParams{XPartnerDomain: partnerDomain},
        paprel.AddJournalJSONRequestBody{
            Currency:    "USD",
            Date:        time.Now().Format(time.DateOnly),
            Description: "First journal",
            Lines: []paprel.JournalLineModel{
                {AccountId: os.Getenv("CASH_ACCOUNT_ID"), Description: "Cash received", Debit: &debit},
                {AccountId: os.Getenv("REVENUE_ACCOUNT_ID"), Description: "Revenue earned", Credit: &credit},
            },
            Posted: &posted,
        })
    if err != nil {
        log.Fatal(err)
    }
    if journal.JSON200 == nil || journal.JSON200.Data == nil {
        log.Fatalf("journal rejected: %d %s", journal.StatusCode(), journal.Body)
    }
    fmt.Println(journal.JSON200.Data.Journal.AnchorId)
}

Java / Kotlin

Generator: OpenAPI Generator with the native library, which uses java.net.http and Jackson. It targets Java 11 or later, and Kotlin code can call it as is.

Shell
npx @openapitools/openapi-generator-cli generate \
  -i https://paprel.com/openapi.json -g java --library native -o paprel-java \
  --additional-properties=groupId=com.example,artifactId=paprel-client,invokerPackage=com.example.paprel,apiPackage=com.example.paprel.api,modelPackage=com.example.paprel.model

The output is a Gradle and Maven project. Build it, or copy src/main/java into your own build. You can also run the generator from the openapi-generator-maven-plugin or the Gradle plugin.

java
import com.example.paprel.ApiClient;
import com.example.paprel.ApiException;
import com.example.paprel.api.AccountingAccountsApi;
import com.example.paprel.api.AccountingJournalsApi;
import com.example.paprel.api.AppConnectApi;
import com.example.paprel.model.*;
import java.time.LocalDate;
import java.util.List;

public class Main {
  static final String BASE_URL = "https://api-sandbox.paprel.com";
  static final String PARTNER_DOMAIN = "sandbox.paprel.com";

  public static void main(String[] args) throws Exception {
    try {
      // 1. Exchange client credentials for a short-lived access token.
      ApiClient anon = new ApiClient();
      anon.updateBaseUri(BASE_URL);
      AppConnectTokenModel token = new AppConnectApi(anon).oauthTokenExchange(
          new OauthTokenExchangeRequest()
              .grantType(OauthTokenExchangeRequest.GrantTypeEnum.CLIENT_CREDENTIALS)
              .clientId(System.getenv("APP_CONNECT_CLIENT_ID"))
              .clientSecret(System.getenv("APP_CONNECT_CLIENT_SECRET")),
          PARTNER_DOMAIN);

      // Every later request carries the bearer token.
      ApiClient paprel = new ApiClient();
      paprel.updateBaseUri(BASE_URL);
      paprel.setRequestInterceptor(req -> req.header("Authorization", "Bearer " + token.getAccessToken()));

      // 2. List the chart of accounts.
      BankingAccountListResponse accounts = new AccountingAccountsApi(paprel).getAccounts(PARTNER_DOMAIN);
      if (accounts.getData() != null) {
        accounts.getData().forEach(a -> System.out.println(a.getId() + " " + a.getAccountCode()));
      }

      // 3. Post a balanced journal.
      BankingJournalFormResponse journal = new AccountingJournalsApi(paprel).addJournal(PARTNER_DOMAIN,
          new BankingJournalFormModel()
              .currency("USD")
              .date(LocalDate.now().toString())
              .description("First journal")
              .lines(List.of(
                  new JournalLineModel().accountId(System.getenv("CASH_ACCOUNT_ID"))
                      .description("Cash received").debit("100.00"),
                  new JournalLineModel().accountId(System.getenv("REVENUE_ACCOUNT_ID"))
                      .description("Revenue earned").credit("100.00")))
              .posted(true));
      System.out.println(journal.getData().getJournal().getAnchorId());
    } catch (ApiException e) {
      System.err.println("Paprel API error " + e.getCode() + ": " + e.getResponseBody());
      System.exit(1);
    }
  }
}

Use updateBaseUri(...) to point the client at a host. setBasePath(...) in this library only sets the path prefix.

PHP

Generator: OpenAPI Generator with the php generator. It produces a Composer package that uses Guzzle and requires PHP 8.1 or later.

Shell
npx @openapitools/openapi-generator-cli generate \
  -i https://paprel.com/openapi.json -g php -o paprel-php \
  --additional-properties=invokerPackage=Paprel
cd paprel-php && composer install
php
<?php
require __DIR__ . '/vendor/autoload.php';

use Paprel\ApiException;
use Paprel\Configuration;
use Paprel\Api\AccountingAccountsApi;
use Paprel\Api\AccountingJournalsApi;
use Paprel\Api\AppConnectApi;
use Paprel\Model\BankingJournalFormModel;
use Paprel\Model\JournalLineModel;
use Paprel\Model\OauthTokenExchangeRequest;

const BASE_URL = 'https://api-sandbox.paprel.com';
const PARTNER_DOMAIN = 'sandbox.paprel.com';

try {
    // 1. Exchange client credentials for a short-lived access token.
    $anon = (new Configuration())->setHost(BASE_URL);
    $token = (new AppConnectApi(null, $anon))->oauthTokenExchange(new OauthTokenExchangeRequest([
        'grant_type' => 'client_credentials',
        'client_id' => getenv('APP_CONNECT_CLIENT_ID'),
        'client_secret' => getenv('APP_CONNECT_CLIENT_SECRET'),
    ]), PARTNER_DOMAIN);

    // Every later request carries the bearer token.
    $config = (new Configuration())->setHost(BASE_URL)->setAccessToken($token->getAccessToken());

    // 2. List the chart of accounts.
    $accounts = (new AccountingAccountsApi(null, $config))->getAccounts(PARTNER_DOMAIN);
    foreach ($accounts->getData() ?? [] as $account) {
        echo $account->getId(), ' ', $account->getAccountCode(), PHP_EOL;
    }

    // 3. Post a balanced journal.
    $journal = (new AccountingJournalsApi(null, $config))->addJournal(PARTNER_DOMAIN, new BankingJournalFormModel([
        'currency' => 'USD',
        'date' => date('Y-m-d'),
        'description' => 'First journal',
        'lines' => [
            new JournalLineModel(['account_id' => getenv('CASH_ACCOUNT_ID'), 'description' => 'Cash received', 'debit' => '100.00']),
            new JournalLineModel(['account_id' => getenv('REVENUE_ACCOUNT_ID'), 'description' => 'Revenue earned', 'credit' => '100.00']),
        ],
        'posted' => true,
    ]));
    echo $journal->getData()->getJournal()->getAnchorId(), PHP_EOL;
} catch (ApiException $e) {
    fwrite(STDERR, "Paprel API error {$e->getCode()}: {$e->getResponseBody()}\n");
    exit(1);
}

Other languages

OpenAPI Generator also targets C#, Ruby, Rust, Swift and Dart, among others. Run npx @openapitools/openapi-generator-cli list to see every generator. We have not run those generators against the Paprel spec, so check the output compiles before you rely on it.

Running the samples

Every sample reads these environment variables:

Shell
export APP_CONNECT_CLIENT_ID="<your client_id>"
export APP_CONNECT_CLIENT_SECRET="<your client_secret>"
export CASH_ACCOUNT_ID="<a cash account id>"
export REVENUE_ACCOUNT_ID="<a revenue account id>"

New to Paprel? Create sandbox credentials first, then pick account IDs from step 2 of the samples or from the 5-minute quickstart.

Two rules apply in every language:

  • Send x-partner-domain on every call. The spec marks it required, so generated methods take it as an argument. In the sandbox it is sandbox.paprel.com. If you'd rather set it once in middleware, strip the parameter from a saved copy of the spec before you generate.
  • Keep the client secret on your server. Cache the access token until shortly before expires_in runs out, then exchange again.

Keeping a generated client current

  • Pin the spec version you generated from, and regenerate when the changelog announces API changes.
  • Run a breaking-change check in CI, such as oasdiff breaking, before you regenerate. The SDK guide has a ready-made GitHub Actions job.
  • Commit the generated code or generate it at build time, but don't edit it by hand. Put retries and logging in a thin wrapper around the generated client.
  • Know what is safe to retry. Journals are not deduplicated, so don't retry a failed journal write blindly. Read webhooks and idempotency and the error codes first.

REST API and webhooks

Underneath the UI components and SDKs, every operation is plain JSON over HTTPS, so curl or any HTTP library is enough. The 5-minute quickstart runs the same three steps as the samples above with curl and jq, and the API reference documents every operation.

Paprel sends signed webhooks when accounting data changes, so your product can react without polling. Webhooks, idempotency and reliable writes covers the signature check, retries, duplicate-safe writes and recovery from missed events.

Partner API

Backend-integrated partners that provision companies and mint user sessions use a separate spec, /openapi-partner.json. Generate a client for it with the same commands, swapping the spec URL. Partner tokens use a private_key_jwt client assertion instead of a client secret, as described in Partner API authentication.

AI agents: MCP

AI agents don't need a generated client. Paprel runs a tenant-scoped MCP server over Streamable HTTP, so Claude, Cursor, the OpenAI Agents SDK or any other MCP client can connect with a scoped token. Writes from an agent land as pending journals for human review. See Connect an AI agent to the Paprel MCP server and Paprel for AI agents.

Reference

Evaluate Paprel

Build in sandbox, launch with a production trial

Use sandbox for developer testing with no billing. When you are ready for real workflows, start production on a monthly plan with a 14-day free trial.

API-First Delivery
Audit-Ready Controls
Sandbox And Guided Rollout
We use cookies to improve your experience.

We use cookies and local storage for essential settings and, with your choices, analytics and advertising. Online identifiers and activity can be personal data. You can reject optional categories or change your choices.

These cookies are necessary for the basic functionality of the website, ensuring a seamless user experience. They cannot be disabled.