Billing API

These endpoints are the Billing page over the API: read your billing state, save your billing details, add a card, manage your subscription, set a spend limit, pay what is owed and download your invoices. They answer for the account the key or session belongs to.

How the answers look

Billing actions run the same checks as the Billing page and answer with the outcome as a short code plus the sentence the page would show. A script can branch on result and show message to a person.

{ "result": "limit", "message": "Spend limit saved." }

A refusal has the same two keys and an error key with the same sentence, like every other API refusal. Its status says whose move it is: 422 for a value to fix (bad, terms, euvat, country, subcount, subfewer, subterm, subterms, subyearonly), 402 when a payment did not go through (paypart, payfail, subdeclined), 403 when the account is billed another way (contract), 409 when something has to happen first (such as details: save your billing details), and 500 for error, where nothing was charged and a retry is safe.

These endpoints stay open on a paused account, so a script can pay what is owed and resume it.

Read your billing

GET /api/billing/ returns what the Billing page shows. It is a read.

GET /api/billing/
curl -s https://eyalsec.com/api/billing/ \
  -H "X-API-Key: es2_EXAMPLEKEYdoNotUse0000000000000000000000"
{
  "billing": "card",
  "enabled": true,
  "status": "active",
  "status_label": "Active",
  "paused_reason": "",
  "card": { "brand": "visa", "last4": "4242", "expires": "12/28" },
  "details": { "company": "Acme Ltd", "email": "bil***me.com", "country": "GB",
               "tax_id": "GB1***789", "address": "1 H***eet", "city": "London", "zip": "N1 1AA" },
  "terms_accepted": true,
  "credit_usd": "$0.00",
  "spend_limit_usd": "500",
  "owed_usd": "$0.00",
  "carried_usd": "$0.00",
  "next_charge_day": "December 1",
  "per_machine": true,
  "machine_price_usd": { "with_raise": "$24.00", "without_raise": "$12.00" },
  "month": {
    "name": "November 2026", "days_elapsed": 14, "days_in_month": 30,
    "so_far_usd": "$84.00", "projected_usd": "$180.00",
    "billed_usd": "$0.00", "unbilled_usd": "$84.00",
    "machines": [],
    "machine_charges": [ { "machine": "web-01", "raise": true, "what": "with Raise, the whole month", "usd": "$24.00" } ],
    "machine_charges_usd": "$84.00",
    "machines_at_event_row_limit": []
  },
  "invoices": [ { "id": 41, "ref": "ES-41", "kind": "month", "period": "October 2026",
                  "period_start": "2026-10-01T00:00:00Z", "period_end": "2026-11-01T00:00:00Z",
                  "status": "paid", "status_label": "Paid", "amount_usd": "$168.00",
                  "number": "30012", "downloadable": true } ],
  "subscription_offered": true,
  "subscription": null,
  "subscription_prices": { "year_with_raise": "$20.00", "year_without_raise": "$10.00" },
  "welcome": { "open": false, "used": "credit", "text": "Your welcome credit of $12.00 was added to your account." }
}
Field Meaning
status none (no card yet), pending, active, past_due, suspended or closed, with the page's wording in status_label.
paused_reason Why the account is paused right now, such as spend_limit or suspended, or empty when it is not.
card, details null until saved. The email, tax number and address are masked, as on the page.
terms_accepted You agreed to the current Terms of Service with your billing details.
month This month so far and the projection at this pace. machines lists the machines billed by the hour, machine_charges the machines charged by the month, and machines_at_event_row_limit any machine whose events this month went past the stored limit.
invoices Your invoices, newest first. downloadable means a document can be fetched.
welcome Your welcome offer. While open is true, offers says what each plan gives (use, machine, prepaid); once used, used names it (credit, machine or prepaid) and text says what you received.
subscription Your es-python subscription (status, term, raise, report, period_end, cancel_at), or null. subscription_prices are the yearly prices, a machine a month.

An account billed by invoice under a signed order gets "billing": "contract" instead, with renewal_date, last_notice_day, prices, documents (each with id, number, status, net, due_on and downloadable) and months (the machines counted each month).

Save billing details

POST /api/billing/details saves the name, address and tax number every invoice carries, the same form as on the Billing page. It is a write.

POST /api/billing/details
Field Meaning
company Required. The name on the invoice.
email Where invoices are sent. Empty keeps the stored one.
country Required. Two-letter code, such as GB.
tax_id Tax or VAT number. Empty keeps the stored one. For a customer in the EU, the company name and an EU VAT number are both needed (euvat otherwise).
address, city, zip The postal address. An empty address keeps the stored one.
accept_terms Required, any non-empty value. It records your agreement to the Terms of Service, the Refund policy and automatic charges, which a card and a subscription both need.
curl -s https://eyalsec.com/api/billing/details \
  -H "X-API-Key: es2_EXAMPLEKEYdoNotUse0000000000000000000000" \
  -d company="Acme Ltd" -d email=billing@example.com -d country=GB -d accept_terms=1
{ "result": "saved", "message": "Billing details saved." }

Add or replace a card

POST /api/billing/card starts adding a card, or replacing the one you have. Card numbers are entered on the payment provider's own page and never reach EyalSec, so the answer is that page's address. Open checkout_url in a browser to finish; the account is active as soon as the card is saved. Save your billing details first.

POST /api/billing/card
{ "result": "checkout",
  "message": "Open checkout_url in a browser to finish on the payment page.",
  "checkout_url": "https://..." }

Choose your plan

POST /api/billing/plan moves your account to another plan, from now. Send plan: use for pay as you go, machine for per machine. The days before today stay on the plan you had, and both are billed after use. Leaving prepaid ends your subscription at once and turns the unused part of what you paid into credit on your account, so save a card first. prepaid answers with how to buy it through your subscription.

POST /api/billing/plan
curl -s https://eyalsec.com/api/billing/plan \
  -H "X-API-Key: es2_EXAMPLEKEYdoNotUse0000000000000000000000" \
  -d plan=use
{ "result": "planuse",
  "message": "Done. You are on pay as you go from now: you pay after, for each run and each hour your machines run." }

Your subscription

POST /api/billing/subscription buys, changes, cancels or keeps your es-python subscription. It is a write, and the field action says which.

POST /api/billing/subscription
action What it does
buy Starts a subscription, by the year. Send the machine counts raise and report; term is year, the default when it is left out. The answer is a checkout_url to finish in a browser, as for a card.
change Sets new counts on your subscription. A higher count is charged now; a lower one starts with the next term, and until then you keep what you paid for (sublower).
cancel Ends the subscription with the current term. Everything keeps working until then.
keep Takes a cancel back.

raise and report together must be at least 1 and cover the es-python machines you already have (subfewer otherwise, naming the count).

curl -s https://eyalsec.com/api/billing/subscription \
  -H "X-API-Key: es2_EXAMPLEKEYdoNotUse0000000000000000000000" \
  -d action=change -d raise=4 -d report=6
{ "result": "subchanged", "message": "Saved. Your subscription has the new counts." }

Set a spend limit

POST /api/billing/spend-limit sets the monthly spend limit, in whole dollars from 1 to 10,000,000. Send clear=1, or an empty limit_usd, to remove it. A higher limit, or none, protects again the machines the old limit paused this month.

POST /api/billing/spend-limit
curl -s https://eyalsec.com/api/billing/spend-limit \
  -H "X-API-Key: es2_EXAMPLEKEYdoNotUse0000000000000000000000" \
  -d limit_usd=500
{ "result": "limit", "message": "Spend limit saved." }

Removing it answers nolimit.

Pay what is owed

POST /api/billing/pay charges the saved card for every unpaid invoice at once. A paused account that ends up owing nothing is active again in the same request.

POST /api/billing/pay
{ "result": "paidall", "message": "Thank you. Everything owed is paid and your account is active." }

nothing means nothing was owed. paypart (402) means the payment did not go through and the account stays paused; try again, or add another card.

Download an invoice

GET /api/billing/invoices/{id}/download returns a link to one invoice's document, with the id from the invoices list. The link is short-lived, so ask for a new one each time. An invoice that is not yours, or has no document yet, is a 404.

GET /api/billing/invoices/{id}/download
curl -s https://eyalsec.com/api/billing/invoices/41/download \
  -H "X-API-Key: es2_EXAMPLEKEYdoNotUse0000000000000000000000"
{ "url": "https://..." }

For an account billed under a signed order, GET /api/billing/contract/documents/{id}/download does the same for a contract document, with the id from documents.

GET /api/billing/contract/documents/{id}/download

Something unclear or missing on this page? Email support@eyalsec.com.

EyalSec Pricing Docs Security Research Vulnerabilities Play Security glossary About Contact עברית Login Get started Protect my Python app