Developer documentation

# BjornTech Swish Platform API

Customer integration guide for merchant onboarding, signed requests, payments, QR codes, refunds and reliable status handling.

Production **https://swish.bjorntech.eu**

<a id="overview"></a>

## Conventions and security

Append every documented route directly to the production base URL. Requests and responses use JSON unless otherwise noted.

Production customer routes require authentication. The fixed public [MSS test endpoints](#mss) are the exception: no onboarding, API credentials or customer-managed Swish certificates are needed.

Examples are illustrative, not live test data. Replace merchant aliases, payment references and URLs with your own configured values. Generate state, nonces and instruction IDs server-side; never reuse the placeholders in production.

For JSON request bodies, send `Content-Type: application/json`. Cancellation uses JSON Patch instead. Copy the body separately from the HTTP method, path and headers; sign the exact bytes you transmit.

### HTTPS only

Use HTTPS for every production request.

### Server-only credentials

Never expose access keys or HMAC secrets in browser or mobile code.

### Authoritative status

Treat the authenticated GET endpoint as the source of truth.

### Stable identifiers

Generate a unique instructionId for each new payment or refund.

<a id="onboarding"></a>

## Merchant onboarding

Before onboarding, the merchant needs a Swish Handel number from their bank with **BjornTech AB (id 9872884581)** as technical provider. See [Get started](/get-started.md) for bank-by-bank instructions.

Onboarding links a merchant account to the integration and returns the credentials required for signed API requests.

| Method | Path | Purpose |
| --- | --- | --- |
| POST | `/v1/onboarding/start` | Start merchant onboarding |
| GET | `/v1/onboarding/confirm?token=...` | Complete confirmation and redirect |
| POST | `/v1/onboarding/exchange` | Exchange one-time code for credentials |

### Start onboarding

`POST /v1/onboarding/start`

| Field | Required | Description |
| --- | --- | --- |
| email | Yes | Merchant email address |
| merchantAlias | Yes | Merchant Swish alias |
| redirectUri or adminReturnUrl | Yes (one) | Browser return URL after confirmation |
| state | No | Opaque state protection value |
| nonce | No | Opaque unique integration value |
| callbackUrl | No | Payment-status callback endpoint |
| siteUrl | No | Merchant-site metadata |
| integrationVersion | No | Integrating application version |

**Onboarding request body**



```json
{
  "email": "merchant@example.com",
  "merchantAlias": "1233801768",
  "redirectUri": "https://merchant.example/admin/swish/return",
  "state": "GENERATE_UNPREDICTABLE_STATE_SERVER_SIDE",
  "nonce": "GENERATE_UNIQUE_NONCE_SERVER_SIDE",
  "callbackUrl": "https://merchant.example/swish/callback",
  "siteUrl": "https://merchant.example",
  "integrationVersion": "1.0.0"
}
```

This example includes optional metadata and callback fields. The required fields are email, merchantAlias and one return URL. Use adminReturnUrl instead of redirectUri only for a supported integration flow. Keep state to validate the browser return. Unknown onboarding fields are rejected.

### Expected onboarding response

**Onboarding response body**



```json
{
  "accountUuid": "11111111-1111-4111-8111-111111111111"
}
```

This response starts onboarding; it does not contain payment credentials. Complete the confirmation and code exchange below.

> Production return URLs must be explicitly configured, absolute HTTPS, externally reachable, and match an approved origin and implemented path. Never derive them from request or forwarding headers, and never fall back to localhost.

### Confirm and exchange

`GET /v1/onboarding/confirm?token=...` returns the browser to the stored URL with `swish_onboarding_code` and `state`. Validate state server-side, exchange the transient code immediately, and clean it from the URL.

Confirmation is a browser GET with no request body. Use the token from the confirmation link, not the exchange code.

**exchange request**



```http
POST /v1/onboarding/exchange
Content-Type: application/json

{ "code": "ex-opaque" }
```

**Exchange request body**



```json
{
  "code": "ex-opaque"
}
```

Replace ex-opaque with the swish\_onboarding\_code received on the validated browser return. It is a one-time code, not an access key.

### Expected exchange response

**Exchange response body (credential placeholders)**



```json
{
  "accessKeyId": "YOUR_ACCESS_KEY_ID",
  "hmacSecret": "YOUR_BASE64_ENCODED_HMAC_SECRET",
  "secret": "YOUR_BASE64_ENCODED_HMAC_SECRET",
  "merchantAlias": "1233801768",
  "accountUuid": "11111111-1111-4111-8111-111111111111"
}
```

The hmacSecret and secret fields contain the same base64-encoded value. The example uses nonfunctional placeholders, not real credentials. Never share or log an actual exchange response.

Store the returned base64 HMAC secret and access key securely on the server. Codes are single-use and expire after 15 minutes by default. Unknown, expired and used codes return `404`, `410` and `409` respectively.

<a id="authentication"></a>

## HMAC authentication

Sign production payment, QR-code, refund, status and cancellation requests with HMAC-SHA256. The fixed public MSS routes do not require signing. For authenticated requests, build exactly seven fields, separated by LF newlines, with no trailing newline.

**canonical request**



```text
METHOD
PATH
QUERY
ACCESS_KEY_ID
TIMESTAMP
NONCE
BODY_SHA256_HEX
```

Use the uppercase method, exact transmitted pathname and encoded query substring, and the lowercase SHA-256 digest of the exact UTF-8 body. Hash the empty string for a bodyless request.

| Required header | Value |
| --- | --- |
| `X-BjornTech-Access-Key` | Assigned accessKeyId |
| `X-BjornTech-Timestamp` | ISO-8601 timestamp with timezone |
| `X-BjornTech-Nonce` | Unique, unpredictable value |
| `X-BjornTech-Signature` | Lowercase hex HMAC-SHA256 signature |

> Base64-decode the HMAC secret once and use the raw bytes as the key. Timestamps must normally be within five minutes. Every retry needs a fresh timestamp, nonce and signature. Never combine these headers with Authorization: Bearer.

<a id="payments"></a>

## Payments

| Method | Path | Purpose |
| --- | --- | --- |
| PUT | `/v1/swish/payment-requests/:instructionId` | Create payment |
| GET | `/v1/swish/payment-requests/:instructionId` | Authoritative status |
| PATCH | `/v1/swish/payment-requests/:instructionId` | Cancel payment |

### Create a payment

`PUT /v1/swish/payment-requests/:instructionId`

| Field | Required | Description |
| --- | --- | --- |
| payeeAlias | Yes | Merchant Swish number |
| amount | Yes | Decimal string, max two decimals |
| currency | Yes | Must be SEK |
| callbackUrl | No | HTTPS status callback; omit for polling only |
| payerAlias | No | Payer mobile number, international format |
| payeePaymentReference | No | Merchant payment reference |
| message | No | Message shown for the payment |

### Minimal request body (polling only)

**Minimal payment request body**



```json
{
  "payeeAlias": "1233801768",
  "amount": "100.00",
  "currency": "SEK"
}
```

The amount is a decimal string in Swedish kronor: "100.00" means 100 SEK, not 100 öre. Currency must be SEK. Calculate the amount and merchant alias on your backend, not from untrusted browser input.

### Request body with optional fields

**payment request**



```json
{
  "payeePaymentReference": "ORDER-10001",
  "callbackUrl": "https://merchant.example/swish/callback",
  "payerAlias": "46712345678",
  "payeeAlias": "1233801768",
  "amount": "100.00",
  "currency": "SEK",
  "message": "Order 10001"
}
```

The extended example adds an HTTPS callback, payer mobile number, merchant reference and message. These fields are optional for payment creation; omit callbackUrl for polling-only operation.

> A successful creation means the payment request was created—not that payment succeeded. Verify using authenticated GET.

### Expected creation response

**Payment creation response body**



```json
{
  "location": "",
  "paymentRequestToken": "",
  "requests": 12,
  "purchasedRequests": 1000,
  "validTo": "2026-10-31",
  "created": "2026-09-01"
}
```

This is a creation wrapper, not a payment-status object. An optional body field is included only when a response body is available. The location and paymentRequestToken strings may be empty, as shown here. The remaining fields describe account usage and validity; they do not prove payment.

When paymentRequestToken is non-empty, use it as token in a [QR-code request](#qr-codes). It is not the instructionId or paymentReference.

### Payment statuses

| Status | Meaning |
| --- | --- |
| CREATED | Created, not complete |
| PAID | Payment successful |
| DECLINED | Payer declined |
| ERROR | Failed or timed out |
| CANCELLED | Payment request cancelled |

### Retrieve payment status (no request body)

**Signed status request (header placeholders)**



```http
GET /v1/swish/payment-requests/0123456789ABCDEF0123456789ABCDEF
X-BjornTech-Access-Key: YOUR_ACCESS_KEY_ID
X-BjornTech-Timestamp: CURRENT_ISO_8601_TIMESTAMP
X-BjornTech-Nonce: FRESH_UNPREDICTABLE_NONCE
X-BjornTech-Signature: COMPUTED_LOWERCASE_HEX_HMAC_SHA256
```

Replace the path ID with the instructionId used to create the payment: 32 uppercase hexadecimal characters, without dashes. GET has no JSON body or query parameters here. Generate all four HMAC headers for this GET request and hash the empty string, not an empty JSON object. The header placeholders above are not valid credentials or a usable signature.

**Payment GET response body (selected fields)**



```json
{
  "id": "0123456789ABCDEF0123456789ABCDEF",
  "payeePaymentReference": "ORDER-10001",
  "paymentReference": "652ED6A2BCDE4BA8AD11D7334E9567B7",
  "status": "PAID"
}
```

This paid-payment example shows selected fields from the payment object, without the creation wrapper. Fields vary by status. Use paymentReference from the successful payment as originalPaymentReference when issuing a refund; it is not the order reference or instructionId.

### Cancel a payment

`PATCH /v1/swish/payment-requests/:instructionId`

Send `Content-Type: application/json-patch+json` and the exact patch below. A payment can only be cancelled before reaching a final state.

**cancellation body**



```json
[
  { "op": "replace", "path": "/status", "value": "cancelled" }
]
```

The cancellation response body can vary. Use authenticated GET afterwards to confirm the final status; the lowercase patch value is distinct from the uppercase CANCELLED status.

<a id="qr-codes"></a>

## QR codes

Create a payment first, then use its paymentRequestToken to request a QR image to present to the customer for scanning in the Swish app.

| Method | Path | Purpose |
| --- | --- | --- |
| POST | `/v1/swish/qr-codes` | Generate QR image |

### Request a QR image

**Signed QR request (header placeholders)**



```http
POST /v1/swish/qr-codes
Content-Type: application/json
X-BjornTech-Access-Key: YOUR_ACCESS_KEY_ID
X-BjornTech-Timestamp: CURRENT_ISO_8601_TIMESTAMP
X-BjornTech-Nonce: FRESH_UNPREDICTABLE_NONCE
X-BjornTech-Signature: COMPUTED_LOWERCASE_HEX_HMAC_SHA256
```

**QR request body**



```json
{
  "format": "svg",
  "token": "token-123",
  "border": 4
}
```

Replace token-123 with the non-empty paymentRequestToken from payment creation. The example requests SVG with border set to 4; these are example values, not defaults. The JSON object is forwarded to Swish for QR generation.

Use the same server-side [HMAC authentication](#authentication) as for payments. Sign POST, the public path /v1/swish/qr-codes and the exact JSON body you send. Generate all four HMAC headers; the placeholders above are not usable credentials or a signature.

### QR image response

**QR response headers (illustrative)**



```http
HTTP/1.1 200 OK
Content-Type: image/svg+xml
```

The response body is the QR image itself, not a JSON wrapper or an image URL. The upstream HTTP status, headers and image bytes are passed through. Read Content-Type to handle the image response; do not assume every response, including errors, contains an image or JSON.

> Generating or scanning a QR code does not confirm payment. Use [authenticated payment GET](#payments) with the original instructionId to verify PAID before fulfilling the order.

<a id="refunds"></a>

## Refunds

| Method | Path | Purpose |
| --- | --- | --- |
| PUT | `/v1/swish/refunds/:instructionId` | Create refund |
| GET | `/v1/swish/refunds/:instructionId` | Authoritative refund status |

### Create a refund

`PUT /v1/swish/refunds/:instructionId`

| Field | Required | Description |
| --- | --- | --- |
| originalPaymentReference | Yes | Reference from the original successful payment |
| payerAlias | Yes | Merchant Swish number issuing the refund |
| amount | Yes | Decimal string; cannot exceed refundable amount |
| currency | Yes | Must be SEK |
| callbackUrl | Yes | HTTPS refund-status endpoint |
| payerPaymentReference | No | Merchant refund reference |
| message | No | Refund message |

**refund request**



```json
{
  "originalPaymentReference": "652ED6A2BCDE4BA8AD11D7334E9567B7",
  "callbackUrl": "https://merchant.example/swish/refund-callback",
  "payerAlias": "1233801768",
  "amount": "100.00",
  "currency": "SEK",
  "payerPaymentReference": "REFUND-10001",
  "message": "Refund for order 10001"
}
```

The refund amount is also a decimal string in SEK. Use the reference from the original successful payment, not a new instructionId. The refund itself needs a new instructionId in its URL. The merchant refund reference and message are optional; the table above marks callbackUrl as required for refunds.

A successful response means Swish accepted the refund for processing. The body may be empty. Retrieve the refund for authoritative status.

### Retrieve refund status (no request body)

`GET /v1/swish/refunds/:instructionId`

Use the refund instructionId in the path, no request body, and the same four HMAC headers shown for payment status. Recompute the signature for the refund path with an empty body.

**Refund GET response body (selected fields)**



```json
{
  "id": "FEDCBA9876543210FEDCBA9876543210",
  "originalPaymentReference": "652ED6A2BCDE4BA8AD11D7334E9567B7",
  "payerPaymentReference": "REFUND-10001",
  "status": "PAID"
}
```

This example shows selected fields from a completed refund object, not a creation acknowledgement. Other fields may be present, and fields vary by status.

### Refund statuses

| Status | Meaning |
| --- | --- |
| CREATED | Created, not complete |
| DEBITED | Amount withdrawn from merchant |
| PAID | Refund successful |
| ERROR | Refund failed |

<a id="callbacks"></a>

## Callbacks and status handling

Payment callbacks are enabled when the payment request includes callbackUrl; omit it for polling-only payments. For refunds, follow the required fields in the refund table above.

Treat callbacks as notifications, never proof of payment.

Correlate identifiers, then use authenticated GET to verify status.

Make callback processing idempotent and tolerant of repeated delivery.

Do not assume callback headers reproduce optional creation fields.

When payment callbacks are enabled, a callback URL configured for your integration during onboarding takes precedence over the payment request URL. Configuring that URL alone does not enable callbacks for a payment that omits callbackUrl.

### Payment callback body

**Payment callback body (selected fields)**



```json
{
  "id": "0123456789ABCDEF0123456789ABCDEF",
  "status": "PAID"
}
```

This example shows only the payment identifier and reported status from a callback notification. It is not a response to your create request and is not authenticated proof of payment. Match id to the payment, then retrieve it with authenticated GET before fulfilling the order. Do not assume this is the complete callback schema.

<a id="mss"></a>

## MSS test endpoints

Swish MSS (Merchant Swish Simulator) simulates payment outcomes and error scenarios. It does not move real money, prove production settlement or reproduce a consumer Swish-app/BankID flow.

Use https://swish.bjorntech.eu with the exact /mss paths below. The prefix selects the test route family, not a separate deployment stage. There is no /v1/swish/mss alias, and arbitrary Swish paths are not supported.

> No login, merchant onboarding, HMAC headers or Bearer token is required. Do not send customer credentials to these public test routes. BjornTech manages the MSS client certificate and mTLS connection to Swish.

> These routes describe the implemented backend contract, not a guarantee of live availability. Confirm deployment, MSS certificate configuration and end-to-end acceptance with BjornTech before relying on hosted MSS testing.

### Payments and refunds

| Method | Path | Purpose |
| --- | --- | --- |
| PUT | `/mss/swish-cpcapi/api/v2/paymentrequests/:instructionId` | Create test payment |
| GET | `/mss/swish-cpcapi/api/v1/paymentrequests/:id` | Retrieve test payment |
| PATCH | `/mss/swish-cpcapi/api/v1/paymentrequests/:id` | Cancel test payment |
| PUT | `/mss/swish-cpcapi/api/v2/refunds/:instructionId` | Create test refund |
| GET | `/mss/swish-cpcapi/api/v1/refunds/:id` | Retrieve test refund |

### Create a test payment without credentials

**Unsigned MSS payment request (polling only)**



```http
PUT https://swish.bjorntech.eu/mss/swish-cpcapi/api/v2/paymentrequests/YOUR_UNIQUE_32_CHARACTER_UPPERCASE_HEX_ID
Content-Type: application/json

{
  "payeePaymentReference": "MSS-TEST-10001",
  "payeeAlias": "1234679304",
  "payerAlias": "4671234768",
  "amount": "100",
  "currency": "SEK",
  "message": "MSS test payment"
}
```

Replace the instruction-ID placeholder with a newly generated, unique 32-character uppercase hexadecimal value, without dashes. The example omits callbackUrl for polling only; add a reachable callback URL if you need notifications.

The required payeeAlias identifies the test merchant; 1234679304 is Swish’s documented public example, not the only allowed alias. The optional payerAlias example 4671234768 identifies a test consumer: include it for e-commerce, or omit it for mobile commerce. Use country-code digits without + or a national trunk zero. Arbitrary valid-looking numbers are not necessarily accepted by MSS.

A successful create only acknowledges creation. Preserve Location if returned. The MSS compatibility response uses snake\_case fields such as payment\_request\_token and purchased\_requests, unlike the canonical production response. Its anonymous usage fields do not describe a customer account.

### Retrieve test status without credentials

**Unsigned MSS status request (no body)**



```http
GET https://swish.bjorntech.eu/mss/swish-cpcapi/api/v1/paymentrequests/YOUR_PAYMENT_ID
```

Use the resource ID from the create response or Location and retrieve through BjornTech, not directly from the upstream Swish URL. GET has no request body or authentication headers. Verify the simulated status after creation or a callback; it is never proof of a real payment.

Cancellation uses the same JSON Patch body shown in the payments section and Content-Type: application/json-patch+json. Refunds use the Swish refund body: originalPaymentReference from the successful test payment, the merchant as required payerAlias, amount, currency and callbackUrl; the consumer payeeAlias is optional. Generate a new instructionId for each refund.

### Recurring MSS operations

Only these seven recurring test operations are supported. Consent approval and applicable bank agreements remain upstream prerequisites; BjornTech does not schedule payments, approve consents or retry automatically.

| Method | Path | Purpose |
| --- | --- | --- |
| POST | `/mss/recurring/merchant/v1/consents/:consentId` | Create test consent |
| POST | `/mss/recurring/merchant/v1/consents/:consentId/token` | Request consent token |
| GET | `/mss/recurring/merchant/v1/consents/:consentId` | Retrieve test consent |
| DELETE | `/mss/recurring/merchant/v1/consents/:consentId` | Delete test consent |
| PUT | `/mss/recurring/merchant/v1/consents/:consentId/callback` | Update consent callback |
| POST | `/mss/recurring/merchant/v1/payments/single/:paymentId` | Create recurring test payment |
| GET | `/mss/recurring/merchant/v1/payments/single/:paymentId/status` | Retrieve recurring test status |

MSS does not advertise the production tin/alias availability checks or single-payment DELETE operation. Use Swish’s recurring API reference for request and callback schemas; recurring consent and payment callbacks are different from ordinary payment callbacks.

### Callbacks, quotas and troubleshooting

Public MSS calls are anonymous: they do not consume customer quota or store customer callback destinations. Validated callback URLs are forwarded directly to MSS, without BjornTech’s customer callback relay. Use a reachable endpoint that accepts JSON POST, and HTTPS for recurring callbacks. Treat notifications as untrusted and verify state through the corresponding MSS GET route.

MSS traffic on the production host shares the source-IP rate limit below, even though it does not consume customer quota. On 429, honor Retry-After and back off; public MSS retries remain unsigned. On 400, check the body, test aliases and instruction ID. On 502, contact BjornTech about upstream or certificate configuration; never bypass TLS checks.

Simulator scenarios and payload details: [Official Swish MSS reference](https://developer.swish.nu/api/mss) and [Swish recurring API reference](https://developer.swish.nu/api/recurring-payments).

<a id="rate-limits"></a>

## Rate limits and retries

~1,000 requests

per source IP over five minutes — approximately 3.3 requests/second average.

On `429 Too Many Requests`, read `Retry-After`, pause the affected source IP for at least that duration, then continue with bounded backoff and jitter. Do not assume the response body is JSON.

> For an uncertain payment or refund create outcome, reuse the same instruction ID and exact payload. Authenticated retries need a fresh timestamp, nonce and signature; public MSS retries remain unsigned.

<a id="errors"></a>

## Errors

Application errors are generally JSON, but upstream and rate-limit responses may be JSON, non-JSON or empty. Use HTTP status as the primary signal and parse bodies defensively.

**Example error response body (HTTP 401)**



```json
{
  "error": "unauthorized"
}
```

This is one application-error example, not a universal envelope. Validation errors may instead be arrays of error objects, and other failures may have no JSON body.

Implementation rule

Never infer undocumented endpoints, SDKs, statuses, browser handoff URLs, authentication methods, response shapes or guarantees.
