Skip to content

External Order Integration

Learn how to create subscription orders from external systems like telesales or automated order processing.

Overview

The Vendor Order API allows authorized vendors to programmatically insert subscription orders into the Sesamy platform. This is typically used by telesales (TM) teams or automated order processing systems that need to create customer contracts via API.

Getting Started

Before using this API, you need to obtain from Sesamy:

  1. OAuth2 Client Credentials - Client ID, Client Secret, and the paymentsContractThirdPartyOnboarding scope
  2. Vendor Configuration - Your vendorId and promotional codes (promoCode) configured for your vendor

INFO

Contact Sesamy to set up your integration credentials and promo codes.

Promo Codes

A promo code represents a specific product at a specific price. Each offer you want to make available via the API requires its own promo code to be configured in Sesamy.

For example, if you want to offer:

  • A 12-month digital subscription at 99 kr/month
  • A 6-month digital subscription at 119 kr/month
  • A print + digital bundle at 149 kr/month

Each of these would need a separate promo code.

To set up promo codes:

  1. List all the offers you want to make available (product, price, billing period)
  2. Send the list to Sesamy for configuration
  3. Sesamy will provide the corresponding promo codes to use in your API requests

Authentication

The API uses OAuth2 Client Credentials flow.

Obtain Access Token

bash
curl -X POST https://token.sesamy.com/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET" \
  -d "scope=paymentsContractThirdPartyOnboarding"

Response:

json
{
  "access_token": "eyJhbGc...",
  "token_type": "Bearer",
  "expires_in": 3600
}

Include the access token in the Authorization header of all API requests:

Authorization: Bearer YOUR_ACCESS_TOKEN

Creating Orders

Endpoint

POST https://api.sesamy.com/payments/vendor/{vendorId}/promos/code/{promoCode}?confirm=true

Creates a new subscription contract for a customer using a promotional code. The confirm=true parameter creates and confirms the contract in a single request.

TIP

Use ?confirm=true to create and confirm contracts in one step, reducing round trips.

Path Parameters

ParameterTypeRequiredDescription
vendorIdstringYesYour vendor identifier
promoCodestringYesThe promotional code for the subscription offer

Query Parameters

ParameterTypeRequiredDescription
confirmbooleanNoSet to true to confirm the contract immediately

Request Body

json
{
  "externalOrderId": "ORDER-2025-001234",
  "quantity": 1,
  "paymentMethod": "INVOICE",
  "paymentProvider": "BILLOGRAM",
  "startDate": "2025-01-08",
  "userData": {
    "email": "customer@example.com",
    "fullName": "John Doe",
    "phone": "+46701234567",
    "address": {
      "firstName": "John",
      "lastName": "Doe",
      "street": "Example Street 123",
      "zip": "12345",
      "city": "Stockholm",
      "country": "SE"
    },
    "extraData": {
      "flowyCustomerNumber": "987654321",
      "seller": "Jane Smith",
      "leadSourceName": "Winter Campaign 2025"
    }
  },
  "vendorData": {
    "promoCode": "PROMOCODE",
    "seller": "tm-team",
    "sellerRequestId": "987654321"
  }
}

Request Body Schema

FieldTypeRequiredDescription
externalOrderIdstringYesYour unique order identifier
quantitynumberNoNumber of subscriptions (default: 1)
paymentMethodstringYesPayment method: INVOICE, CARD, SWISH
paymentProviderstringYesPayment provider: BILLOGRAM, STRIPE
startDatestringNoContract start date (YYYY-MM-DD)
userDataobjectYesEnd user/subscriber information
userData.emailstringYesCustomer email address
userData.fullNamestringNoCustomer full name
userData.phonestringNoCustomer phone number
userData.addressobjectNoCustomer address
userData.address.countrystringNoCountry code (ISO 3166-1 alpha-2)
userData.extraDataobjectNoAdditional custom data
ownerDataobjectNoPayer information (if different from user)
vendorDataobjectNoVendor-specific metadata

INFO

If ownerData is not provided, the system assumes the user is also the payer.

Response

Status: 200 OK

json
{
  "contractId": "f1dc9c2a-bf9f-4151-ab98-443c02280df9",
  "responseKey": "CONTRACT_CREATED_AND_CONFIRMED"
}
FieldTypeDescription
contractIdstringUnique identifier for the created contract
responseKeystringStatus of the operation
delayedContractStartsAtstringStart date if contract is delayed

Response Keys:

KeyDescription
CONTRACT_CREATEDContract created but not confirmed
CONTRACT_CREATED_AND_CONFIRMEDContract created and confirmed successfully
SKIPPED_ALREADY_CONFIRMEDContract was already confirmed

Complete Example

bash
# 1. Get access token
ACCESS_TOKEN=$(curl -s -X POST https://token.sesamy.com/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=YOUR_CLIENT_ID" \
  -d "client_secret=YOUR_CLIENT_SECRET" \
  -d "scope=paymentsContractThirdPartyOnboarding" | jq -r '.access_token')

# 2. Create and confirm order
curl -X POST "https://api.sesamy.com/payments/vendor/YOUR_VENDOR_ID/promos/code/PROMOCODE?confirm=true" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "externalOrderId": "ORDER-2025-001234",
    "quantity": 1,
    "paymentMethod": "INVOICE",
    "paymentProvider": "BILLOGRAM",
    "startDate": "2025-01-08",
    "userData": {
      "email": "customer@example.com",
      "fullName": "John Doe",
      "phone": "+46701234567",
      "address": {
        "firstName": "John",
        "lastName": "Doe",
        "street": "Example Street 123",
        "zip": "12345",
        "city": "Stockholm",
        "country": "SE"
      }
    },
    "vendorData": {
      "promoCode": "PROMOCODE",
      "seller": "tm-team"
    }
  }'

Error Handling

Common Errors

ErrorStatusCauseSolution
UserEmailRequiredError400Missing userData.emailProvide customer email
InvalidAddressError400Invalid address formatVerify country code is ISO 3166-1 alpha-2
Unauthorized401Invalid or expired tokenObtain a new access token
Forbidden403Client not authorized for vendorVerify vendorId matches your credentials
PromoCodeNotFoundError404Invalid promo codeVerify promo code with Sesamy
ConflictError409Duplicate externalOrderIdUse a unique order ID
InvalidSMNOError422Non-numeric vendorData.SMNOUse only numbers for SMNO

Error Response Format

json
{
  "error": "UserEmailRequiredError",
  "message": "User email is required for promo contract creation"
}

Best Practices

  1. Use unique order IDs - Always use a unique externalOrderId for each order to prevent duplicates

  2. Validate data before sending - Validate on your side to reduce errors:

    • Email format
    • Phone number format
    • Country codes (ISO 3166-1 alpha-2)
  3. Handle token expiry - Tokens expire after 1 hour. Implement refresh logic.

  4. Check before retrying - If you receive a network error, check if the order was created before retrying to avoid duplicates

  5. Log responses - Log all API responses with the externalOrderId for troubleshooting

Troubleshooting

Order Not Created

  • Verify your access token is valid and not expired
  • Check that the vendorId matches your OAuth2 client configuration
  • Ensure the promo code is configured for your vendor

Duplicate Order Error

  • Check if an order with the same externalOrderId already exists
  • Use a unique identifier for each new order

Authentication Failed

  • Verify your client credentials
  • Ensure you're requesting the correct scope: paymentsContractThirdPartyOnboarding

Next Steps

Released under the MIT License.