-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
8021 lines (7868 loc) · 299 KB
/
Copy pathopenapi.yaml
File metadata and controls
8021 lines (7868 loc) · 299 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: Vatly API
version: '1.0'
x-generated-at: '2026-05-28'
description: |
Vatly is a Merchant of Record billing platform for European SaaS companies.
This API enables you to manage checkouts, customers, orders, subscriptions, refunds, and more.
## Authentication
The Vatly API uses Bearer token authentication. All API requests must include an `Authorization` header:
```
Authorization: Bearer {your_api_token}
```
### Live vs Test Mode
API tokens determine the environment mode:
- Tokens prefixed with `live_` access **production** data
- Tokens prefixed with `test_` access **sandbox** data
Resources created in one mode cannot be accessed or referenced from the other mode.
For example, a checkout created with a test token cannot reference a customer created with a live token.
#### Payment methods in test mode
A few payment methods work in live mode but cannot be completed in test mode,
because the payment provider cannot settle them there. A test-mode checkout
still lists them, greyed out and labelled as unavailable, so you can see they
exist without being able to select one:
| Method | Test mode | Reason |
|--------|-----------|--------|
| `banktransfer` | Not selectable | The provider cannot settle bank transfers in test mode |
| `paybybank` | Not selectable | The provider cannot settle Pay by Bank in test mode |
Every other method behaves identically in both modes. Test a checkout with any
selectable method — `creditcard` and `ideal` cover the one-off and mandate flows —
and the resulting orders, invoices and webhooks are the same ones live mode produces.
## Pagination
List endpoints use cursor-based pagination with the following query parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| `limit` | integer | Number of results per page (default: 10, max: 100) |
| `startingAfter` | string | Cursor ID to fetch results after |
| `endingBefore` | string | Cursor ID to fetch results before |
`startingAfter` and `endingBefore` are mutually exclusive.
All list responses are wrapped in a pagination envelope:
```json
{
"data": [ ... ],
"count": 2,
"links": {
"self": { "href": "https://api.vatly.com/v1/orders", "type": "application/json" },
"next": { "href": "https://api.vatly.com/v1/orders?startingAfter=order_abc", "type": "application/json" },
"prev": null
}
}
```
## Money Format
All monetary values are represented as objects with `value` (string) and `currency` (ISO 4217 code):
```json
{
"value": "99.99",
"currency": "EUR"
}
```
Values are strings to preserve decimal precision.
## Email Format
Vatly canonicalizes every email address it accepts, and stores and returns
that canonical form:
- the local part is lower-cased;
- the domain is lower-cased and converted to its **Punycode (ASCII)** form
per [UTS #46](https://www.unicode.org/reports/tr46/).
So `User@Müller.de`, `USER@MÜLLER.DE` and `user@xn--mller-kva.de` are all
accepted and all describe the same address. **Responses return the canonical
form, which may therefore differ in spelling from what you submitted** —
compare addresses after canonicalizing, or key off the resource `id`.
Submitting an internationalized domain directly is fine; you do not need to
encode it yourself. A domain that cannot be canonicalized at all — an empty
label (`user@..com`), a malformed Punycode label (`user@xn--0.com`), a label
over 63 characters — is rejected with `422`.
Beyond that canonicalization the comparison is exact: `büyer@example.com`
and `straße@example.com` are different addresses from `buyer@example.com`
and `strasse@example.com`, and get their own customers.
For human-friendly display in your own UI, decode the domain back to
Unicode. Most languages provide this in the standard library — for
example, PHP's `idn_to_utf8()`, Python's `idna.decode()`, or Node's
[`url.domainToUnicode()`](https://nodejs.org/api/url.html#urldomaintounicodedomain).
Local-part Unicode (EAI / SMTPUTF8) is not supported for delivery, but a
non-ASCII local part is stored and compared verbatim (after lower-casing).
## Idempotency
All mutating requests (`POST`, `PATCH`, `PUT`, `DELETE`) accept an
optional `Idempotency-Key` header. When present, Vatly records the
first response keyed by `(token, endpoint, key)` and returns it
verbatim on subsequent requests with the same key, marking the
replay with an `Idempotent-Replayed: true` response header.
- **Use a fresh key per logical operation.** Generate one client-side
(UUIDv4 is recommended) and retry transparently with the same key
on network errors.
- **Keys are bound to the exact parameters of the first request.**
The method, public endpoint, concrete path, query, body, normalized
`Content-Type` media type, and normalized ordered `Content-Encoding` are
contract-significant. Replaying with a different value returns
`409 Conflict` without executing again. Either retry with the original
parameters or generate a new key.
- **Keys expire after 24 hours.** After that the key is reusable as
a fresh idempotency boundary.
- **Scope is per public route URI template.** The same key value on a
different endpoint is treated as a new key. Internal route-name or
controller refactors do not change replay identity.
- **The first HTTP response is final for that key.** This includes a
rendered `4xx` or `5xx` response after request processing started.
Retry the exact request with the same key to retrieve that response;
use a fresh key for corrected parameters only after reconciling whether
the original mutation took effect.
- **Exact replays still consume rate-limit budget.** API and per-merchant
write throttles run before the idempotency lookup. An otherwise valid
replay can therefore return `429 Too Many Requests` instead of the stored
response. Wait for its `Retry-After` interval, then resend the exact same
request and key.
- **A `409` with `details.idempotency_outcome = in_progress` is
retryable.** Wait the number of seconds in `Retry-After`, then resend the
exact same request and key.
- **A `409` with `details.idempotency_outcome = unknown` is not
retryable.** The mutation may have completed but its response is not
replayable. Read and reconcile the affected resource before taking any
further mutating action; never automatically retry with either the same
or a fresh key.
Sending an `Idempotency-Key` on a `GET` or `HEAD` request is ignored.
## Handling failed subscription payments
When a subscription renewal payment fails, Vatly runs an automated
**payment recovery** process (dunning) on your behalf. You never have to
schedule your own retries — but you do decide when to restrict access.
**What happens, and what you receive:**
1. The renewal payment fails and recovery begins. You receive a single
**`order.payment_failed`** webhook for the renewal order (sent once, when
recovery starts — not on each retry). The subscription's `status` stays
`active` throughout recovery: it does **not** move to a "past due" state,
and `on_grace_period` is never used for payment failure — that status
means a *voluntary* cancellation that keeps access until the period ends.
2. Vatly attempts to recover the payment, and how it does so depends on why
the charge failed:
- **Soft decline** (e.g. insufficient funds, a temporary decline): the
payment method is still valid, so Vatly automatically re-attempts the
charge over a multi-week window, emailing the customer along the way.
- **Hard decline** (e.g. an expired, canceled or invalid payment method):
retrying cannot succeed, so Vatly instead prompts the customer to
supply a new payment method, on a shorter window.
3. **If recovery succeeds**, the original renewal order is paid and you
receive **`order.paid`** for that same order. Because the subscription was
never interrupted, access simply continues — nothing else is needed.
4. **If recovery is exhausted** (the customer never resolves it), Vatly
cancels the subscription: you receive **`subscription.canceled_for_nonpayment`**
and the subscription `status` becomes `canceled` with
`cancellationReason: payment_failure`.
**Recommended integration** — gate access on the events, not on a timer you
keep in sync with ours:
- On `order.payment_failed`: keep access on, and start your own grace period
if your product has one.
- On `order.paid` for the same order: recovery succeeded — clear that grace
period.
- If your grace period elapses with no matching `order.paid`: restrict access
on your side if you wish. Vatly's recovery keeps running underneath, so a
later `order.paid` lets you restore access automatically.
- On the subscription's cancellation: remove access permanently.
The number of retry attempts and the exact retry cadence are operational
details that Vatly tunes over time. Integrate against these webhook events
rather than against specific durations or attempt counts.
## Errors
The API returns standard HTTP status codes and JSON error responses:
| Status | Description |
|--------|-------------|
| 400 | Bad Request - Invalid request format |
| 401 | Unauthorized - Missing or invalid token |
| 403 | Forbidden - Token invalid or insufficient permissions |
| 404 | Not Found - Resource doesn't exist |
| 409 | Conflict - idempotency mismatch, request still in progress, outcome unknown, or concurrent write |
| 422 | Unprocessable Entity - Validation failed |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error |
contact:
name: Vatly Support
url: https://vatly.com
email: support@vatly.com
license:
name: Proprietary
url: https://vatly.com/terms
servers:
- url: https://api.vatly.com/v1
description: Production API
- url: https://api.staging.vatly.com/v1
description: Staging API
security:
- BearerAuth: []
tags:
- name: Checkouts
description: |
Create and manage hosted checkout sessions.
Checkouts allow customers to purchase one-off products and subscription plans through a hosted payment page.
- name: Customers
description: |
Manage customer records.
Customers are identified by email and can have multiple subscriptions and orders.
- name: One-Off Products
description: |
Create and view one-off products.
Products can be created in the Vatly dashboard or through the API. Live
products are reviewed and approved by Vatly before they can be added to
checkouts.
- name: Subscription Plans
description: |
Create and view subscription plans.
Plans define recurring billing intervals and pricing, and can be created
in the Vatly dashboard or through the API. Live plans are reviewed and
approved by Vatly before they can be added to checkouts.
- name: Orders
description: |
View orders and request invoice address updates.
Orders are created when checkouts complete or subscriptions renew.
- name: Refunds
description: |
Create and manage refunds for paid orders.
Supports both partial (per-item) and full refunds.
- name: Chargebacks
description: |
View chargebacks initiated by the payment provider.
Chargebacks are created automatically when a customer disputes a payment.
- name: Subscriptions
description: |
Manage customer subscriptions.
Update plans, quantities, billing details, or cancel subscriptions.
- name: Webhook Events
description: |
View webhook events that were sent to your webhook endpoints.
Each event contains the full resource payload at the time the event occurred.
- name: Webhook Endpoints
description: |
Register and manage the endpoints Vatly delivers webhook events to.
Create, list, update, and delete endpoints programmatically — useful for
CI, infrastructure-as-code, and ephemeral preview environments. The
signing secret is write-only: you supply it and it is never returned.
- name: Test Helpers
description: |
Sandbox-only endpoints for simulating billing events.
These endpoints require a `test_` prefixed API token.
paths:
/checkouts:
get:
operationId: listCheckouts
summary: List all checkouts
description: |
Returns a paginated list of checkouts for the authenticated merchant.
Results are filtered by the testmode determined from the API token.
tags:
- Checkouts
parameters:
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/startingAfter'
- $ref: '#/components/parameters/endingBefore'
responses:
'200':
description: List of checkouts
content:
application/json:
schema:
type: object
required:
- data
- count
- links
additionalProperties: false
properties:
data:
type: array
items:
$ref: '#/components/schemas/Checkout'
count:
type: integer
description: Number of items in the current page
example: 1
links:
$ref: '#/components/schemas/PaginationLinks'
example:
data:
- id: checkout_QdEpFhdSrG4Y3DnfsdqsH
resource: checkout
customerId: null
orderId: null
testmode: false
redirectUrlSuccess: https://example.com/success
redirectUrlCanceled: https://example.com/canceled
metadata: {}
locale: null
status: created
expiresAt: '2024-01-16T10:30:00Z'
createdAt: '2024-01-15T10:30:00Z'
links:
checkoutUrl:
href: https://checkout.vatly.com/checkout_QdEpFhdSrG4Y3DnfsdqsH
type: text/html
self:
href: https://api.vatly.com/v1/checkouts/checkout_QdEpFhdSrG4Y3DnfsdqsH
type: application/json
order: null
count: 1
links:
self:
href: https://api.vatly.com/v1/checkouts
type: application/json
next: null
prev: null
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/ValidationFailed'
default:
$ref: '#/components/responses/UnexpectedError'
post:
operationId: createCheckout
summary: Create a checkout
description: |
Creates a new hosted checkout session.
The checkout URL in the response can be used to redirect customers to complete their purchase.
Checkouts expire after a configurable period (default: 24 hours).
**Products:**
- Include one or more products using their `one_off_product_` or `subscription_plan_` IDs
- Mix one-off products and subscription plans in the same checkout
- Override prices for specific products using the `price` field
- Add trial periods to subscription plans using `trialDays`
**Customer association:**
- Optionally link to an existing customer using `customerId`
- If not provided, a new customer is created based on checkout form input
tags:
- Checkouts
parameters:
- $ref: '#/components/parameters/idempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCheckoutRequest'
examples:
oneOffProduct:
summary: Checkout with one-off product (with {CHECKOUT_ID} placeholder)
value:
redirectUrlSuccess: https://example.com/return?checkout_id={CHECKOUT_ID}
redirectUrlCanceled: https://example.com/canceled?checkout_id={CHECKOUT_ID}
products:
- id: one_off_product_Vr8kQdFhSrG4Y3DnfsdqH
quantity: 1
subscriptionWithTrial:
summary: Subscription plan with trial
value:
redirectUrlSuccess: https://example.com/success
redirectUrlCanceled: https://example.com/canceled
customerId: customer_Fp2kQrSvWm8NjLhYbUcP
locale: de
products:
- id: subscription_plan_Bm7xNvPwKr3YjTgHcZaE
trialDays: 14
customPrice:
summary: Product with custom price
value:
redirectUrlSuccess: https://example.com/success
redirectUrlCanceled: https://example.com/canceled
products:
- id: one_off_product_Vr8kQdFhSrG4Y3DnfsdqH
quantity: 2
price:
value: '49.99'
currency: EUR
metadata:
campaign: summer-sale
responses:
'201':
description: Checkout created successfully
headers:
Idempotent-Replayed:
$ref: '#/components/headers/IdempotentReplayed'
content:
application/json:
schema:
$ref: '#/components/schemas/Checkout'
example:
id: checkout_Bm7xNvPwKr3YjTgHcZaE
resource: checkout
customerId: null
orderId: null
testmode: false
redirectUrlSuccess: https://example.com/success
redirectUrlCanceled: https://example.com/canceled
metadata:
campaign: summer-sale
locale: de
status: created
expiresAt: '2024-01-16T10:30:00Z'
createdAt: '2024-01-15T10:30:00Z'
links:
checkoutUrl:
href: https://checkout.vatly.com/checkout_Bm7xNvPwKr3YjTgHcZaE
type: text/html
self:
href: https://api.vatly.com/v1/checkouts/checkout_Bm7xNvPwKr3YjTgHcZaE
type: application/json
order: null
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'409':
$ref: '#/components/responses/Conflict'
'422':
description: |
Unprocessable Entity - The request was well-formed but contained validation errors.
This includes the case where a referenced resource (e.g. `customerId`) exists but
was created in a different mode — switch between live/test API tokens to access it.
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
examples:
validationFailed:
summary: Field validation failed
value:
message: The given data was invalid.
errors:
products.0.id:
- The selected products.0.id is invalid.
testmodeMismatch:
summary: Referenced resource exists but in the wrong mode
value:
message: The given data was invalid.
errors:
customerId:
- Customer exists, but the wrong mode is used. Try switching live / test API keys.
default:
$ref: '#/components/responses/UnexpectedError'
/checkouts/{checkoutId}:
get:
operationId: getCheckout
summary: Get a checkout
description: |
Retrieves a specific checkout by its ID.
Use this to check the status of a checkout or get the order ID after completion.
tags:
- Checkouts
parameters:
- $ref: '#/components/parameters/checkoutId'
responses:
'200':
description: Checkout details
content:
application/json:
schema:
$ref: '#/components/schemas/Checkout'
example:
id: checkout_QdEpFhdSrG4Y3DnfsdqsH
resource: checkout
customerId: customer_7kBmRtPvXw2NjLhYcZaE
orderId: order_Jk4pQrSvWm8NjLhYbUcP
testmode: false
redirectUrlSuccess: https://example.com/return?checkout_id=checkout_QdEpFhdSrG4Y3DnfsdqsH
redirectUrlCanceled: https://example.com/canceled
metadata:
campaign: summer-sale
locale: null
status: paid
expiresAt: '2024-01-16T10:30:00Z'
createdAt: '2024-01-15T10:30:00Z'
links:
checkoutUrl:
href: https://checkout.vatly.com/checkout_QdEpFhdSrG4Y3DnfsdqsH
type: text/html
self:
href: https://api.vatly.com/v1/checkouts/checkout_QdEpFhdSrG4Y3DnfsdqsH
type: application/json
order:
href: https://api.vatly.com/v1/orders/order_Jk4pQrSvWm8NjLhYbUcP
type: application/json
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/UnexpectedError'
/customers:
get:
operationId: listCustomers
summary: List all customers
description: |
Returns a paginated list of customers for the authenticated merchant.
Results are filtered by the testmode determined from the API token.
Pass `email` to filter the list down to the customers holding an address —
the way back to a customer id you no longer have.
tags:
- Customers
parameters:
- $ref: '#/components/parameters/customerEmailFilter'
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/startingAfter'
- $ref: '#/components/parameters/endingBefore'
responses:
'200':
description: List of customers
content:
application/json:
schema:
type: object
required:
- data
- count
- links
additionalProperties: false
properties:
data:
type: array
items:
$ref: '#/components/schemas/Customer'
count:
type: integer
description: Number of items in the current page
example: 2
links:
$ref: '#/components/schemas/PaginationLinks'
example:
data:
- id: customer_7kBmRtPvXw2NjLhYcZaE
resource: customer
testmode: false
email: john.doe@example.com
name: John Doe
createdAt: '2024-01-15T10:30:00Z'
metadata:
userId: user_Qp8kNvBxKw7RjTgYcZaE
links:
self:
href: https://api.vatly.com/v1/customers/customer_7kBmRtPvXw2NjLhYcZaE
type: application/json
- id: customer_Lp3mNvBxKw7RjTgYcZaE
resource: customer
testmode: false
email: jane.smith@acme.com
name: Jane Smith
createdAt: '2024-01-10T08:15:00Z'
metadata: {}
links:
self:
href: https://api.vatly.com/v1/customers/customer_Lp3mNvBxKw7RjTgYcZaE
type: application/json
count: 2
links:
self:
href: https://api.vatly.com/v1/customers
type: application/json
next: null
prev: null
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'422':
$ref: '#/components/responses/ValidationFailed'
default:
$ref: '#/components/responses/UnexpectedError'
post:
operationId: createCustomer
summary: Create a customer
description: |
Creates a customer, or returns the one that already holds the address.
Customers are uniquely identified by email within a storefront and
testmode, and this endpoint is get-or-create on that key: posting an
address that already exists returns the existing customer rather than a
validation error, so an integration that lost its Vatly customer id can
always get back to it. The status code says which happened:
| Status | Meaning |
| --- | --- |
| `201` | The customer was created by this request. |
| `200` | A customer with this email already existed and is returned unchanged. |
A `200` response never modifies the customer — `name` and `metadata` in
the request body are ignored for an existing customer. Use
`PATCH /v1/customers/{customerId}` to change one.
A `201` can also complete a create that was interrupted before it
finished, in which case the customer keeps the `id` and `createdAt` of
that earlier attempt — so `createdAt` may predate the request. Treat it as
when the customer came into being, not as when this call happened.
Addresses are canonicalized before they are compared, so `User@MÜLLER.de`
and `user@xn--mller-kva.de` are the same customer. Beyond that the
comparison is exact — `büyer@example.com` is a different mailbox and gets
its own customer.
**Use cases:**
- Pre-create customers before checkout
- Link existing users from your system to Vatly
- Recover the customer id for a known email after a re-sync or reset
tags:
- Customers
parameters:
- $ref: '#/components/parameters/idempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCustomerRequest'
example:
email: customer@example.com
metadata:
userId: user_Qp8kNvBxKw7RjTgYcZaE
responses:
'200':
description: |
A customer with this email already existed. It is returned unchanged —
nothing in the request body was applied.
headers:
Idempotent-Replayed:
$ref: '#/components/headers/IdempotentReplayed'
content:
application/json:
schema:
$ref: '#/components/schemas/Customer'
example:
id: customer_7kBmRtPvXw2NjLhYcZaE
resource: customer
testmode: false
email: customer@example.com
name: John Doe
createdAt: '2024-01-15T10:30:00Z'
metadata:
userId: user_Qp8kNvBxKw7RjTgYcZaE
links:
self:
href: https://api.vatly.com/v1/customers/customer_7kBmRtPvXw2NjLhYcZaE
type: application/json
'201':
description: Customer created successfully
headers:
Idempotent-Replayed:
$ref: '#/components/headers/IdempotentReplayed'
content:
application/json:
schema:
$ref: '#/components/schemas/Customer'
example:
id: customer_7kBmRtPvXw2NjLhYcZaE
resource: customer
testmode: false
email: customer@example.com
name: John Doe
createdAt: '2024-01-15T10:30:00Z'
metadata:
userId: user_Qp8kNvBxKw7RjTgYcZaE
links:
self:
href: https://api.vatly.com/v1/customers/customer_7kBmRtPvXw2NjLhYcZaE
type: application/json
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'409':
$ref: '#/components/responses/Conflict'
'422':
$ref: '#/components/responses/ValidationFailed'
default:
$ref: '#/components/responses/UnexpectedError'
/customers/{customerId}:
get:
operationId: getCustomer
summary: Get a customer
description: Retrieves a specific customer by their ID.
tags:
- Customers
parameters:
- $ref: '#/components/parameters/customerId'
responses:
'200':
description: Customer details
content:
application/json:
schema:
$ref: '#/components/schemas/Customer'
example:
id: customer_7kBmRtPvXw2NjLhYcZaE
resource: customer
testmode: false
email: john.doe@example.com
name: John Doe
createdAt: '2024-01-15T10:30:00Z'
metadata:
userId: user_Qp8kNvBxKw7RjTgYcZaE
links:
self:
href: https://api.vatly.com/v1/customers/customer_7kBmRtPvXw2NjLhYcZaE
type: application/json
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/UnexpectedError'
patch:
operationId: updateCustomer
summary: Update a customer
description: |
Updates a customer's identity fields. Only `name` and `email` may be
changed here, and both are optional — send whichever you want to update.
Billing-address details (company name, tax ID, street, city, country,
etc.) are not supported by this endpoint and are ignored; amend those
through the hosted billing-update flow, which validates tax-relevant
data centrally so invoices stay accurate.
An `email` is canonicalized before it is stored, so the address you read
back may differ in spelling from the one you sent. Moving a customer onto
an address another customer in the same storefront and mode already holds
returns `422`.
tags:
- Customers
parameters:
- $ref: '#/components/parameters/customerId'
- $ref: '#/components/parameters/idempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateCustomerRequest'
example:
name: John Doe
email: new.email@example.com
responses:
'200':
description: Customer updated successfully
headers:
Idempotent-Replayed:
$ref: '#/components/headers/IdempotentReplayed'
content:
application/json:
schema:
$ref: '#/components/schemas/Customer'
example:
id: customer_7kBmRtPvXw2NjLhYcZaE
resource: customer
testmode: false
email: new.email@example.com
name: John Doe
createdAt: '2024-01-15T10:30:00Z'
metadata:
userId: user_Qp8kNvBxKw7RjTgYcZaE
links:
self:
href: https://api.vatly.com/v1/customers/customer_7kBmRtPvXw2NjLhYcZaE
type: application/json
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'422':
$ref: '#/components/responses/ValidationFailed'
default:
$ref: '#/components/responses/UnexpectedError'
/customers/{customerId}/portal-sessions:
post:
operationId: createCustomerPortalSession
summary: Create a hosted customer portal session
description: |
Creates a short-lived, single-use link that sends an authenticated
customer directly to this API token's storefront in Vatly's hosted
portal. The session is locked to the customer, storefront, merchant, and
live/test mode represented by the token; it never exposes a storefront
picker or other stores associated with the same email address.
Redirect the customer's browser to `url`. The link expires after roughly
15 minutes by default and can be consumed once. If an idempotency key
replays a response after its URL has already been used, request a
replacement with a fresh key.
tags:
- Customers
parameters:
- $ref: '#/components/parameters/customerId'
- $ref: '#/components/parameters/idempotencyKey'
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/CreatePortalSessionRequest'
example:
returnUrl: https://merchant.example/account/billing
responses:
'201':
description: Hosted customer portal session created
headers:
Idempotent-Replayed:
$ref: '#/components/headers/IdempotentReplayed'
Cache-Control:
description: Prevents storage of the credential-bearing response.
schema:
type: string
example: no-store, private
Pragma:
description: Legacy proxy fallback preventing storage of the credential-bearing response.
schema:
type: string
example: no-cache
content:
application/json:
schema:
$ref: '#/components/schemas/PortalSession'
example:
url: https://billing.vatly.com/authenticate?credential=...
expiresAt: '2026-09-01T12:15:00Z'
returnUrl: https://merchant.example/account/billing
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'422':
$ref: '#/components/responses/ValidationFailed'
default:
$ref: '#/components/responses/UnexpectedError'
/customers/{customerId}/subscriptions:
get:
operationId: listCustomerSubscriptions
summary: List customer subscriptions
description: |
Returns a paginated list of subscriptions for a specific customer.
Includes subscriptions in all states (active, canceled, etc.).
tags:
- Customers
- Subscriptions
parameters:
- $ref: '#/components/parameters/customerId'
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/startingAfter'
- $ref: '#/components/parameters/endingBefore'
responses:
'200':
description: List of customer's subscriptions
content:
application/json:
schema:
type: object
required:
- data
- count
- links
additionalProperties: false
properties:
data:
type: array
items:
$ref: '#/components/schemas/Subscription'
count:
type: integer
description: Number of items in the current page
example: 1
links:
$ref: '#/components/schemas/PaginationLinks'
example:
data:
- id: subscription_Lp3mNvBxKw7RjTgYcZaE
resource: subscription
customerId: customer_Lp3mNvBxKw7RjTgYcZaE
subscriptionPlanId: subscription_plan_Rk5pQrSvWm8NjLhYbUcP
testmode: false
name: Pro Monthly
description: Full access to all Pro features
billingAddress:
fullName: John Doe
companyName: Acme Corp
streetAndNumber: 123 Main Street
city: Berlin
postalCode: '10115'
country: DE
basePrice:
value: '29.00'
currency: EUR
quantity: 1
interval: month
intervalCount: 1
status: active
cancellationReason: null
mandate:
method: card
maskedIdentifier: '4242'
startedAt: '2024-01-15T10:30:00Z'
endedAt: null
canceledAt: null
renewedAt: '2024-02-15T10:30:00Z'
renewedUntil: '2024-03-15T10:30:00Z'
nextRenewalAt: '2024-03-15T10:30:00Z'
trialUntil: null
scheduledUpdate: null
links:
self:
href: https://api.vatly.com/v1/subscriptions/subscription_Lp3mNvBxKw7RjTgYcZaE
type: application/json
customer:
href: https://api.vatly.com/v1/customers/customer_Lp3mNvBxKw7RjTgYcZaE
type: application/json
count: 1
links:
self:
href: https://api.vatly.com/v1/customers/customer_Lp3mNvBxKw7RjTgYcZaE/subscriptions
type: application/json
next: null
prev: null
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/ValidationFailed'
default:
$ref: '#/components/responses/UnexpectedError'
/customers/{customerId}/subscriptions/{subscriptionId}:
get:
operationId: getCustomerSubscription
summary: Get a customer subscription
description: |
Retrieves a specific subscription for a customer.
The subscription must belong to the specified customer.
tags:
- Customers
- Subscriptions
parameters:
- $ref: '#/components/parameters/customerId'
- $ref: '#/components/parameters/subscriptionId'
responses:
'200':
description: Subscription details
content:
application/json:
schema:
$ref: '#/components/schemas/Subscription'
example:
id: subscription_Lp3mNvBxKw7RjTgYcZaE
resource: subscription