API versionv2 next

API v2 is not live yet: it launches in early 2027, and until then these pages are its spec. Switch to v1 (live)

Create subscriber

Create a link to the payment window, where the payer saves their card, so that you can charge it later. Only the payer can save it, so this is the only way to create a subscriber.

Request

POST https://api.gjold.com/v2/{shopid}:sub/new

The key needs the payid permission.

Headers

HTTP header Description
Authorization

Required. Your API key, after Basic and base64-encoded. See Authentication.

Content-Type application/json. We don't check it.

Fields

Field Type Description
ref string Your reference for the subscriber, such as your customer ID, which seq returns with the subscriber and with each of its charges. We don't check that it is unique, and store it as it is: to change a subscriber's card, renew it rather than create another.
items array

A first charge, for the payer to pay as they save their card: one or more items, whose totals add up to more than 0, in one currency. See First charge.

items[].total amount, required

The price of the item, its whole quantity together. At least 0, and with no more decimals than the currency has. See Amounts.

items[].quantity integer

How many, a positive integer. The default is 1. It is for your records and the dashboard: the "total" is already for all of them.

items[].name string

The name of the product or service, for your records and the dashboard. The payment window does not show it.

items[].sku string

Your SKU for the product.

orderid string

Your ID for the order that the first charge pays, which seq returns with the charge, and the acquirer passes to the payer's bank as its reference, as for a payment link.

autocapture boolean

Capture the first charge as soon as it is authorized. By default, false, it is only authorized, and you capture it later. With true, a capture that fails voids the authorization, and nothing is saved.

billing object The payer's billing address, which seq returns with the subscriber, and with each charge that gives none of its own. See Addresses.
shipping object The shipping address, likewise.
successurl string

Where the payment window sends the payer when they have paid, with a GET and nothing added to the URL. Without it, the window shows a confirmation of its own. We don't check it, so make it an absolute https URL that works, and put in it what the page needs, such as your order ID. It is no proof of payment: see Orders and payment links.

language string

The payment window's language: "da", "en", "no", or "sv". A code with a region, such as "en-GB", counts as its language. Without one, or with another, the window takes the language from the payer's browser, and else uses English.

lifetime string

How long the link can be paid: a whole number and a unit, d, h, m, or s, as in "90m" or "7d". The default is "1h", and it can be from "5m" to "30d". The payer must be done, 3-D Secure included, before it ends. The longer the lifetime, the longer the link's ID: see The link's ID.

First charge

With "items", the payer pays a first charge as they save their card, such as a subscription's first month: one payment, authorized together with saving the card, for the items' total. If it fails, nothing is saved, and the payer can try again in the window. Seq returns it as a charge of the subscriber, after the subscriber, with the "orderid" and items of this request. Like any payment, it is declined if the bank approves only part of it.

Without "items", the payer only saves their card, and is charged nothing. "orderid" and "autocapture" are for the first charge, and do nothing without it.

Example

A link where the payer saves their card, and pays the first month:

curl https://api.gjold.com/v2/{shopid}:sub/new \
    -u {apikey} \
    -d @create.json
{
    "ref": "user7192",
    "orderid": "M-7192-2026-11",
    "items": [
        {
            "name": "Membership, first month",
            "total": "99 DKK"
        }
    ],
    "billing": {
        "name": "Anne Jensen",
        "email": "anne@example.com"
    },
    "successurl": "https://shop.example/welcome?user=7192"
}

Response

We answer 200 OK with the link, as Create payment link does:

Field Type Description
url string

The link: the payment window's address, to send the payer to.

id string

The link's ID, the {payid} by which you can delete it. Store it with the order.

No subscriber exists yet. We create it when the payer has saved their card, and seq returns it then, with your "ref" and the "id" by which you charge it. If the link expires unused, there is no subscriber, and seq returns nothing.

The payment window offers the payment methods that can be saved: cards, and Apple Pay. MobilePay can't be saved, so it is not offered. To take the payer to Apple Pay, add a parameter to the link's URL:

Link parameter What it does
?go=applepay Opens the payment window with Apple Pay in focus.

If the payer's device can't use Apple Pay, the parameter does nothing. The window always asks the payer's bank for 3-D Secure when they save a card, as the card schemes require of a stored card's first payment; Apple Pay authenticates on the device.

Errors

Besides the errors that any request can give, which Errors lists:

Status and message Description
400 invalid json in {where}: {why} The body is not a JSON object, or a field is not as the table says. See Invalid JSON.
400 total must be more than 0 There are "items", but their totals add up to 0. Leave them out to charge nothing.
400 invalid item total currency An item's total is in a currency that is not in the ISO 4217 table.
400 invalid lifetime The "lifetime" can't be read, or is under "5m" or over "30d".
500 {why} We could not create the link just now. Try again.

A declined card is not an error of this request: the payer sees the decline in the payment window, and can try again there until the link expires. The request takes no Idempotency-Key, so a retry after a broken connection can create a second link. That does no harm, as no one has the first link's URL, and it expires unpaid.

See also

Subscribers, Charge subscriber, Renew subscriber, Charging subscribers, and in the knowledge base, Stored credentials.