> For the complete documentation index, see [llms.txt](https://docs.ecommerce.seb.ee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecommerce.seb.ee/integration/api-client-sdk/quickstarts/node.js-typescript.md).

# Node.js / TypeScript

Set up the Node.js / TypeScript SDK, initiate a sandbox payment, and configure client adapters.

## Prerequisites

* Node.js 20 or later. The package is ESM-only and ships TypeScript types.
* Sandbox API credentials: **client ID** and **client secret**, plus your **participant ID** and **shop agreement ID**. Register and generate these yourself at the **Merchant Portal**: <https://merchantportal.ecommerce.sebgroup.com>.
* The SDK **distribution ZIP**, downloaded from this documentation site.

## Install

Download `egw-js-sdk-<version>.zip` and its matching `.sha256` file, verify the download, then unzip it next to your project:

```bash
sha256sum -c egw-js-sdk-<version>.zip.sha256

unzip egw-js-sdk-<version>.zip -d egw-sdk
```

That gives you `egw-sdk/tieto-egw-sdk-<version>.tgz` — an ordinary npm package tarball — alongside a `README.txt` and a `SHA256SUMS` manifest. Install it from your project:

```bash
npm install ./egw-sdk/tieto-egw-sdk-<version>.tgz
```

The package name is `@tieto/egw-sdk`, and its runtime dependencies are `axios` and `jose`. npm resolves those from your normal registry, so the install needs network access to it.

## Create a client and make your first call

In this example, the credentials are retrieved from environment variables — never commit or log real credentials. All operations are `async`.

```ts
import { DefaultEgwClientFactory, CitPaymentChannel } from "@tieto/egw-sdk";
import { randomUUID } from "node:crypto";

const client = new DefaultEgwClientFactory().create({
  baseUri: new URL("https://sandbox.api.ecommerce.sebgroup.com"),
  authentication: {
    tokenEndpoint: new URL("https://api.ecommerce.sebgroup.com/auth/realms/participants-seb/protocol/openid-connect/token"),
    clientId: process.env.EGW_CLIENT_ID!,
    clientSecret: process.env.EGW_CLIENT_SECRET!,
  },
  jwkUri: new URL("https://checkout.ecommerce.sebgroup.com/api/keys/card-encryption.jwk"),
});

const response = await client.payments().initiateCitPaymentWithBuilder(randomUUID(), (b) =>
  b.channel(CitPaymentChannel.Browser)
   .instructedAmountBuilder((a) => a.amount("100.00").currency("EUR"))
   .orderNumber("ORD-001")
   .participantId(process.env.EGW_PARTICIPANT_ID!)
   .shopAgreementId(process.env.EGW_SHOP_AGREEMENT_ID!)
   .shopRedirectUrl("https://shop.example.com/return")
   .description("First sandbox payment")
);

console.log("Payment created:", response.paymentId);
```

Amounts are **decimal strings** (`"100.00"`), currencies ISO 4217 alpha-3. For test cards and magic values, see [Sandbox test data](/guides/sandbox.md).

## Customizing the client

* You may supply your own HTTP client (adapter) implementation.
* Webhooks: the Node.js SDK does not start a listener; expose your own HTTP endpoint and parse payloads with `client.notifications().parseWebhook()` — see [Security mechanics](/integration/api-client-sdk/guides/security-mechanics.md#webhook-notifications).
* See [Overriding SDK adapters](/integration/api-client-sdk/guides/overriding-sdk-adapters.md) for a full walkthrough of replacing adapters application-wide.

## Next steps

* [Security mechanics](/integration/api-client-sdk/guides/security-mechanics.md) — card encryption for card checkout sessions, webhooks.
* [Error handling](/integration/api-client-sdk/guides/error-handling.md) — the exception hierarchy and retry guidance.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ecommerce.seb.ee/integration/api-client-sdk/quickstarts/node.js-typescript.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
