# Quick Start

> Create a project, test an invoice and signed webhook in Sandbox, then create live credentials and accept a first real mainnet payment.

## Create an account

Sign in at [paymos.io](/_public) with an email magic link, Google, Telegram (OIDC), or a passkey — no password to set.

## Create a project

Open [**Dashboard → Projects → New project**](/projects/create), name the project, and enable the asset and network pairs your customers will use.

## Get your test API keys

Navigate to [**Dashboard → Developer → API Keys**](/developers/api) and generate a test key pair:

:::dash-list
- **Payment Key** (`pk_test_…`) — used to create test invoices and read invoice status
- **API Secret** (`sk_test_…`) — used to compute the HMAC-SHA256 request signature (see the warning below)
:::

:::warning
API Secret never leaves your server. Never send it in headers, query strings, or client code. Never commit it to git — rotate immediately if it leaks.
:::

## Register a test webhook endpoint

Expose your server's webhook handler at an HTTPS URL, then open [**Dashboard → Developer → Webhooks**](/developers/webhooks) in Sandbox and create an endpoint. Enter the HTTPS callback URL, select the `Invoice` category and your project, then create the endpoint. Copy the one-time `whsec_test_…` secret to your server; it is separate from the API key pair and signs test webhook deliveries.

## Create a test invoice

Use an official server SDK below. It serializes the request, creates the exact
HMAC signature, sets the timestamp headers, applies safe retries, and returns a
typed response. Manual signing is documented separately in [Authentication](/docs/authentication.md).

```curl
API_KEY_ID="pk_live_xxxxxxxxxxxx"
API_SECRET="sk_live_xxxxxxxxxxxx"
BODY='{"project_id":"prj_xxxxxxxxxxxx","amount":"100.00","currency":"USD","external_order_id":"order-123","client_id":"customer-456"}'

TS=$(date +%s)
BODY_HASH=$(printf '%s' "$BODY" | openssl dgst -sha256 -hex | sed 's/^.* //')
SIGNATURE=$(printf '%s\n%s\n%s\n%s\n%s' "$TS" POST /v1/invoices '' "$BODY_HASH" \
  | openssl dgst -sha256 -hmac "$API_SECRET" -binary | base64)

curl -sS https://api.paymos.io/v1/invoices \
  -H "Authorization: HMAC-SHA256 $API_KEY_ID:$SIGNATURE" \
  -H "X-Request-Timestamp: $TS" \
  -H "Content-Type: application/json" \
  -d "$BODY"
```

```mcp
Setup once in terminal: `npx -y @paymos/mcp setup`

Prompt:
Read `paymos://docs/hosted-checkout` and integrate Paymos invoice
creation into my backend using the official SDK for this project's
stack. Then use `@paymos/mcp` in sandbox to call `create_invoice`
(`project_id`: `prj_xxxxxxxxxxxx`, `amount`: `"100.00"`, `currency`:
`"USD"`, `external_order_id`: `"order-123"`) and run
`simulate_invoice_payment` (`stage`: `"paid"`) to verify the flow.
```

```javascript
import { Paymos, externalOrderId } from '@paymos/sdk';

const paymos = new Paymos({
  apiKey: process.env.PAYMOS_API_KEY,
  apiSecret: process.env.PAYMOS_API_SECRET,
});

const invoice = await paymos.invoices.create({
  projectId: 'prj_xxxxxxxxxxxx',
  amount: '100.00',
  currency: 'USD',
  externalOrderId: externalOrderId('order'),
  clientId: 'customer-456',
});

console.log(invoice.invoiceId, invoice.paymentUrl);
```

```python
import os

from paymos import Paymos

paymos = Paymos(
    api_key=os.environ["PAYMOS_API_KEY"],
    api_secret=os.environ["PAYMOS_API_SECRET"],
)
invoice = paymos.invoices.create(
    project_id="prj_xxxxxxxxxxxx",
    amount="100.00",
    currency="USD",
    external_order_id="order-123",
    client_id="customer-456",
)

print(invoice["invoice_id"], invoice["payment_url"])
```

```php
<?php
use Paymos\Client;
use Paymos\ClientConfig;
use Paymos\IdempotencyKey;

$paymos = new Client(new ClientConfig(
    getenv('PAYMOS_API_KEY'),
    getenv('PAYMOS_API_SECRET')
));
$invoice = $paymos->invoices()->create(array(
    'project_id' => 'prj_xxxxxxxxxxxx',
    'amount' => '100.00',
    'currency' => 'USD',
    'external_order_id' => IdempotencyKey::externalOrderId('order'),
    'client_id' => 'customer-456',
));

echo $invoice['invoice_id'] . ' ' . $invoice['payment_url'];
```

```go
package main

import (
	"context"
	"fmt"
	"os"

	paymos "github.com/Paymos-labs/go-sdk/v2"
)

func main() {
	client, err := paymos.NewClient(os.Getenv("PAYMOS_API_KEY"), os.Getenv("PAYMOS_API_SECRET"))
	if err != nil {
		panic(err)
	}
	invoice, err := client.Invoices.Create(context.Background(), paymos.CreateInvoiceParams{
		ProjectID:       "prj_xxxxxxxxxxxx",
		Amount:          "100.00",
		Currency:        "USD",
		ExternalOrderID: "order-123",
		ClientID:        stringPointer("customer-456"),
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(invoice.InvoiceID, invoice.PaymentURL)
}

func stringPointer(value string) *string { return &value }
```

```csharp
using Paymos;

using var paymos = new PaymosClient(
    Environment.GetEnvironmentVariable("PAYMOS_API_KEY")!,
    Environment.GetEnvironmentVariable("PAYMOS_API_SECRET")!);

var invoice = await paymos.Invoices.CreateAsync(new CreateInvoiceRequest(
    ProjectId: "prj_xxxxxxxxxxxx",
    Amount: "100.00",
    Currency: "USD",
    ExternalOrderId: "order-123",
    ClientId: "customer-456"));

Console.WriteLine($"{invoice.InvoiceId} {invoice.PaymentUrl}");
```

```java
import io.paymos.CreateInvoiceRequest;
import io.paymos.Invoice;
import io.paymos.PaymosClient;

PaymosClient paymos = new PaymosClient(
    System.getenv("PAYMOS_API_KEY"),
    System.getenv("PAYMOS_API_SECRET"));

Invoice invoice = paymos.invoices.create(
    CreateInvoiceRequest.builder()
        .projectId("prj_xxxxxxxxxxxx")
        .amount("100.00")
        .currency("USD")
        .externalOrderId("order-123")
        .clientId("customer-456")
        .build());

System.out.println(invoice.invoiceId() + " " + invoice.paymentUrl());
```

```ruby
require 'paymos'

paymos = Paymos::Client.new(
  api_key: ENV.fetch('PAYMOS_API_KEY'),
  api_secret: ENV.fetch('PAYMOS_API_SECRET')
)
invoice = paymos.invoices.create(
  project_id: 'prj_xxxxxxxxxxxx',
  amount: '100.00',
  currency: 'USD',
  external_order_id: 'order-123',
  client_id: 'customer-456'
)

puts "#{invoice.invoice_id} #{invoice.payment_url}"
```

```rust
use paymos::{CreateInvoiceRequest, PaymosClient};

let paymos = PaymosClient::new(
    std::env::var("PAYMOS_API_KEY")?,
    std::env::var("PAYMOS_API_SECRET")?,
)?;
let invoice = paymos
    .invoices()
    .create(&CreateInvoiceRequest {
        project_id: "prj_xxxxxxxxxxxx".to_owned(),
        amount: "100.00".to_owned(),
        currency: "USD".to_owned(),
        external_order_id: "order-123".to_owned(),
        network: None,
        customer_fee_percent: None,
        client_id: Some("customer-456".to_owned()),
        products: None,
    })
    .await?;

println!("{} {}", invoice.invoice_id, invoice.payment_url);
```

## Open checkout

The response includes a `payment_url`. Redirect your customer there or embed the same URL with `?embed=true`:

```json
{
  "invoice_id": "inv_5CcyDYmMUGtzYL10q0Iimr",
  "project_id": "prj_xFukZuAJZR06pLVBh3uwzv",
  "status": "awaiting_client",
  "is_final": false,
  "is_test": true,
  "payment_url": "https://checkout.paymos.io/invoice/inv_5CcyDYmMUGtzYL10q0Iimr",
  "order": {
    "external_id": "order-123",
    "client_id": "customer-456",
    "amount": "100.00",
    "currency": "USD"
  },
  "created_at": 1743594000,
  "updated_at": 1743594000,
  "expires_at": 1743597600
}
```

The customer sees a payment page with the wallet address, QR code, and countdown timer. They can pay with any asset + network enabled on the project — see [Supported Currencies](/docs/supported-currencies.md).

On a Telegram-bot project that same `payment_url` opens the Paymos bot instead. The payer picks the asset and network there, gets the address and QR code, and follows the status without leaving Telegram — and without a Paymos account.

See [Hosted Checkout](/docs/hosted-checkout.md) for redirect mode, iframe embed mode, and browser event handling.

## Handle the webhook

When the payment is confirmed, Paymos sends a POST to your registered webhook URL:

```json
{
  "event_id": "evt_J7EEYeL9pZJukfj2c5OQ44",
  "event_type": "invoice.paid",
  "version": 1,
  "occurred_at": 1739281200,
  "data": {
    "invoice_id": "inv_5CcyDYmMUGtzYL10q0Iimr",
    "project_id": "prj_xFukZuAJZR06pLVBh3uwzv",
    "status": "paid",
    "is_final": true,
    "is_test": false,
    "payment_url": "https://checkout.paymos.io/invoice/inv_5CcyDYmMUGtzYL10q0Iimr",
    "order": {
      "external_id": "order-12345",
      "client_id": "customer-67890",
      "amount": "100.00",
      "currency": "USD"
    },
    "payment": {
      "currency": "USDT",
      "network": "TRC20",
      "chain_id": 728126428,
      "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
      "expected": "50.00",
      "address": "TN3W4H6rK2ce4vX9YnFQHwKENnHjoxb3m9",
      "exchange_rate": "2.00",
      "paid": "50.00",
      "remaining": "0",
      "fee": "0.50",
      "net": "49.50",
      "transfers": [
        {
          "tx_hash": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
          "amount": "50.00",
          "status": "confirmed",
          "created_at": 1739281020,
          "confirmed_at": 1739281200,
          "required_confirmations": 19,
          "estimated_confirmation_at": 1739281080,
          "explorer_url": "https://tronscan.org/#/transaction/abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
        }
      ]
    },
    "expires_at": 1739284200,
    "completed_at": 1739281200,
    "created_at": 1739277600,
    "updated_at": 1739281200
  }
}
```

Verify the `X-Webhook-Signature` header and fulfill the order.

:::danger
Never fulfill an order from a browser event (`paymos:succeeded` or iframe `postMessage`). Only the signed server-side webhook is authoritative — browser signals can be spoofed.
:::

```javascript
import { WebhookVerifier } from '@paymos/sdk';

const verifier = new WebhookVerifier(process.env.PAYMOS_WEBHOOK_SECRET);

// Keep the body as a Buffer until verification succeeds.
const event = verifier.constructEvent(signatureHeader, rawBody);
console.log(event.eventId, event.eventType, event.data);
```

```mcp
Setup once in terminal: `npx -y @paymos/mcp setup`

Prompt:
Read `paymos://docs/webhooks` and add a Paymos webhook endpoint to my
backend that verifies `X-Webhook-Signature` over the unparsed raw
request body using `WebhookVerifier` from the official SDK and
deduplicates deliveries by `event_id`. Use `@paymos/mcp` tool
`verify_webhook_signature` to test valid and tampered signatures.
```

```python
import os

from paymos import WebhookVerifier

verifier = WebhookVerifier(os.environ["PAYMOS_WEBHOOK_SECRET"])

# Keep raw_body as bytes until verification succeeds.
event = verifier.construct_event(signature_header, raw_body)
print(event["event_id"], event["event_type"], event["data"])
```

```php
<?php
use Paymos\Webhook\WebhookEvent;
use Paymos\Webhook\WebhookVerifier;

$verifier = new WebhookVerifier(getenv('PAYMOS_WEBHOOK_SECRET'));

// Keep $rawBody unchanged until verification succeeds.
$payload = $verifier->decodeVerifiedPayload($signatureHeader, $rawBody);
$event = new WebhookEvent($payload);
echo $event->id() . ' ' . $event->type();
```

```go
package main

import (
	"fmt"
	"os"
	"time"

	paymos "github.com/Paymos-labs/go-sdk/v2"
)

type invoiceEventData struct {
	InvoiceID string `json:"invoice_id"`
}

func handleWebhook(signatureHeader string, rawBody []byte) error {
	verifier, err := paymos.NewWebhookVerifier(os.Getenv("PAYMOS_WEBHOOK_SECRET"), 5*time.Minute)
	if err != nil {
		return err
	}
	var event paymos.WebhookEvent[invoiceEventData]
	if err := verifier.ConstructEvent(signatureHeader, rawBody, time.Now(), &event); err != nil {
		return err
	}
	fmt.Println(event.EventID, event.EventType, event.Data.InvoiceID)
	return nil
}
```

```csharp
using Paymos;

var verifier = new WebhookVerifier(
    Environment.GetEnvironmentVariable("PAYMOS_WEBHOOK_SECRET")!);

// Keep rawBody as ReadOnlySpan<byte> until verification succeeds.
var webhook = verifier.ConstructEvent<InvoiceEventData>(signatureHeader, rawBody);
Console.WriteLine($"{webhook.EventId} {webhook.EventType} {webhook.Data.InvoiceId}");

public sealed record InvoiceEventData(string InvoiceId);
```

```java
import com.fasterxml.jackson.databind.JsonNode;
import io.paymos.WebhookEvent;
import io.paymos.WebhookVerifier;
import java.time.Instant;

WebhookVerifier verifier = new WebhookVerifier(System.getenv("PAYMOS_WEBHOOK_SECRET"));

// Keep rawBody as byte[] until verification succeeds.
WebhookEvent<JsonNode> event =
    verifier.constructEvent(signatureHeader, rawBody, Instant.now());
System.out.println(event.eventId() + " " + event.eventType() + " " + event.data());
```

```ruby
require 'paymos'

verifier = Paymos::WebhookVerifier.new(ENV.fetch('PAYMOS_WEBHOOK_SECRET'))

# Keep raw_body as the original String until verification succeeds.
event = verifier.construct_event(signature_header, raw_body)
puts "#{event.event_id} #{event.event_type} #{event.data}"
```

```rust
use paymos::{Invoice, WebhookEvent, WebhookVerifier};

let verifier = WebhookVerifier::new(std::env::var("PAYMOS_WEBHOOK_SECRET")?)?;

// Keep raw_body as &[u8] until verification succeeds.
let event: WebhookEvent<Invoice> = verifier.construct_event(signature_header, raw_body)?;
println!("{} {} {}", event.event_id, event.event_type, event.data.invoice_id);
```

## Simulate the test payment

Use the [payment simulator](/docs/invoices/simulate-payment.md) to mark the test invoice paid. Do not send real assets to a test invoice. Confirm that your registered endpoint receives the signed event and that your server verifies it with `whsec_test_…` before fulfilling the order.

## Move to Production

Once the Sandbox (`Test`) request and signed webhook work, switch to Production (`Live`) in the dashboard. There is no manual approval step. Switching the environment does not create keys: open **Dashboard → Developer → API Keys** and create separate live credentials (`pk_live_…` and `sk_live_…`). Register the live webhook endpoint separately and store its `whsec_live_…` secret apart from the test secret.

In Production, Paymos automatically runs AML/KYT screening on incoming payments and outgoing withdrawals at no extra fee (Sandbox is never screened; see [AML/KYC Policy](/aml)).

## Accept your first real mainnet payment

Repeat the invoice request with the live credentials, open the returned `payment_url` — the checkout page, or the Paymos bot on a Telegram-bot project — and send a supported asset on an enabled mainnet network. Paymos detects the transfer and sends the signed live webhook after the required confirmations.

The normal self-serve flow from sign-up to a first real mainnet payment takes about 10 minutes. This is an onboarding benchmark, not an SLA: confirmation time still depends on the network, amount, and current blockchain conditions.

## Next steps

:::dash-list
- [API Keys](/docs/api-keys.md) — credential types, scope, lifecycle
- [Server SDKs](/docs/server-sdks.md) — official clients for eight language ecosystems
- [MCP Server & AI Plugins](/docs/mcp.md) — connect Claude Code, Codex, Cursor, and other AI agents
- [Hosted Checkout](/docs/hosted-checkout.md) — redirect and iframe embed options
- [Refunds](/docs/refunds/create.md) — server-calculated full and overpayment refunds
- [Testing](/docs/testing.md) — how to test in sandbox
- [Webhooks](/docs/webhooks.md) — signature verification and retry policy
:::

## Quick visual guide {#quick-visual-guide}

1. **Create scoped API keys.** Open **Developer → API Keys** to manage separate **Payment** (`pk_...`) and **Payout** (`rk_...`) keys, restrict payout keys with an IP whitelist, and inspect the HMAC-SHA256 signing headers.

   ![Paymos API Keys page showing live Payment and Payout keys, IP whitelist count, and HMAC-SHA256 header reference](/img/guides/host-to-host/01-api-keys.webp)

2. **Inspect signed webhook deliveries.** Under **Developer → Webhooks**, open any event to verify the JSON payload (`invoice.paid`, amounts, network, and fee fields) alongside HTTP delivery attempts and response times.

   ![Paymos webhook event detail showing signed invoice.paid JSON payload and HTTP 200 delivery attempt](/img/guides/host-to-host/02-webhooks-delivered.webp)

3. **Test endpoints in the built-in playground.** Switch to the **Playground** tab inside the dashboard API docs to build `POST /v1/invoices` requests, preview signed headers and JSON bodies, and run live calls in Sandbox.

   ![Paymos dashboard API Playground building a POST /v1/invoices request with live headers and JSON preview](/img/guides/host-to-host/03-endpoint-playground.webp)
