@conto_finance/sdk 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -839,6 +839,311 @@ declare function verifyPurchaseWebhook(input: {
839
839
  data: PurchaseEvent;
840
840
  };
841
841
 
842
+ /**
843
+ * Shared budgets: one limit that several agents draw on, set in Spending controls.
844
+ *
845
+ * `conto.spending` uses an agent key. `admin.spending` is for the budget holder and uses an
846
+ * organization API key. Exact amounts are decimal strings. These APIs never give agents authority
847
+ * to raise ceilings.
848
+ */
849
+ /**
850
+ * File bytes. `new Blob()`, `new File()` and `new Response()` accept them on every supported
851
+ * TypeScript, with or without the DOM lib.
852
+ */
853
+ type DownloadBytes = ReturnType<Uint8Array['slice']> & {
854
+ readonly buffer: ArrayBuffer;
855
+ };
856
+ type SpendingRequester = {
857
+ download(path: string): Promise<DownloadBytes>;
858
+ request<T>(method: string, path: string, body?: Record<string, unknown> | FormData): Promise<T>;
859
+ };
860
+ interface BudgetSnapshot {
861
+ id: string;
862
+ name: string;
863
+ scope: string;
864
+ currency: string;
865
+ period: 'ONCE' | 'MONTHLY';
866
+ periodStart: string;
867
+ periodEnd: string;
868
+ authorizationStartsAt?: string;
869
+ authorizationEndsAt?: string;
870
+ amount: string;
871
+ held: string;
872
+ settled: string;
873
+ refunded: string;
874
+ available: string;
875
+ status: string;
876
+ isActive: boolean;
877
+ version: number;
878
+ requiresTask: boolean;
879
+ taskRequestId: string | null;
880
+ participantIds?: string[];
881
+ }
882
+ interface TaskInput {
883
+ purpose: string;
884
+ amount: string;
885
+ currency: string;
886
+ expiresAt: string;
887
+ permittedMerchants?: string[];
888
+ permittedSourceIds?: string[];
889
+ }
890
+ interface TaskSnapshot {
891
+ id: string;
892
+ purpose: string;
893
+ status: string;
894
+ amount: string;
895
+ currency: string;
896
+ expiresAt: string;
897
+ budgetId: string | null;
898
+ agentId: string;
899
+ participantIds: string[];
900
+ permittedMerchants: string[];
901
+ permittedSourceIds: string[];
902
+ }
903
+ /** A purchase against shared budgets. These are separate from Commerce `conto.purchases`. */
904
+ interface PurchaseSnapshot {
905
+ id: string;
906
+ agentId: string;
907
+ executionReference: string;
908
+ sourceType: string;
909
+ sourceId: string;
910
+ merchant: string;
911
+ purpose: string;
912
+ currency: string;
913
+ authorizedAmount: string;
914
+ heldAmount: string;
915
+ settledAmount: string;
916
+ refundedAmount: string;
917
+ status: string;
918
+ enforcementMode: string;
919
+ verification: string;
920
+ nextActions: string[];
921
+ taskRequestId: string | null;
922
+ department: string | null;
923
+ project: string | null;
924
+ accountingCode: string | null;
925
+ createdAt: string;
926
+ }
927
+ interface PurchaseDetail extends PurchaseSnapshot {
928
+ events: Array<{
929
+ id: string;
930
+ kind: string;
931
+ createdAt: string;
932
+ evidenceRef: string;
933
+ heldAmount: string;
934
+ settledAmount: string;
935
+ refundedAmount: string;
936
+ }>;
937
+ evidence: Array<{
938
+ id: string;
939
+ filename: string;
940
+ matchStatus: string;
941
+ createdAt: string;
942
+ }>;
943
+ }
944
+ interface PreviewInput {
945
+ amount: string;
946
+ currency: string;
947
+ sourceId: string;
948
+ merchant: string;
949
+ purpose?: string;
950
+ taskRequestId?: string;
951
+ purchaseKey?: string;
952
+ }
953
+ interface BudgetInput {
954
+ name: string;
955
+ scope: 'WORKSPACE' | 'AGENT' | 'AGENTS';
956
+ participantIds?: string[];
957
+ amount: string;
958
+ currency: string;
959
+ period: 'ONCE' | 'MONTHLY';
960
+ periodStart: string;
961
+ periodEnd: string;
962
+ requiresTask?: boolean;
963
+ }
964
+ declare class SpendingClient {
965
+ private client;
966
+ constructor(client: SpendingRequester);
967
+ /**
968
+ * CSV of this agent's purchases against budgets in its own organization. Fails with `reasonCode`
969
+ * `EXPORT_TOO_LARGE` above 10,000 purchases.
970
+ */
971
+ exportPurchases(): Promise<DownloadBytes>;
972
+ downloadEvidence(purchaseId: string, evidenceId: string): Promise<DownloadBytes>;
973
+ /** The budgets that cover this agent, with what is held, settled and available. */
974
+ budgets(): Promise<{
975
+ snapshotAt: string;
976
+ timezone: string;
977
+ budgets: BudgetSnapshot[];
978
+ buyerConnection?: {
979
+ revoked: boolean;
980
+ participantId: string;
981
+ };
982
+ }>;
983
+ tasks(cursor?: string): Promise<{
984
+ tasks: TaskSnapshot[];
985
+ nextCursor: string | null;
986
+ }>;
987
+ /**
988
+ * Ask the budget holder to approve a task budget. Once it is approved, pass its id as
989
+ * `context.taskRequestId` on `payments.request()` from a managed wallet, or as `taskRequestId` on
990
+ * `connectedCards.draw()`. A task's budget applies only to a payment or draw that names the task,
991
+ * and it stops nothing on other paths.
992
+ */
993
+ requestTask(input: TaskInput): Promise<{
994
+ id: string;
995
+ status: string;
996
+ nextActions: string[];
997
+ }>;
998
+ /** This agent's purchases against budgets in its own organization. Empty when none has applied. */
999
+ purchases(cursor?: string): Promise<{
1000
+ purchases: PurchaseSnapshot[];
1001
+ nextCursor: string | null;
1002
+ }>;
1003
+ purchase(purchaseId: string): Promise<PurchaseDetail>;
1004
+ /**
1005
+ * Check a purchase against shared budgets before requesting the payment. It holds nothing and
1006
+ * approves nothing. `sourceId` must be a managed wallet linked to this agent, and `currency` must
1007
+ * be that wallet's stablecoin, such as `USDC` on Base, `USDC.e` on Tempo or `pathUSD` on Tempo
1008
+ * Testnet. A purchase the budgets would refuse throws a `ContoError`.
1009
+ */
1010
+ preview(input: PreviewInput): Promise<{
1011
+ budgetCheck: string;
1012
+ configured: boolean;
1013
+ authorizationGranted: false;
1014
+ scope: "SHARED_BUDGET_ONLY";
1015
+ snapshotAt: string;
1016
+ nextActions: string[];
1017
+ }>;
1018
+ /**
1019
+ * Attach a PDF, PNG or JPEG of at most 2 MiB, with up to 10 files per purchase. Set the Blob's
1020
+ * `type` to `application/pdf`, `image/png` or `image/jpeg`. A Blob with no type, or with a type
1021
+ * that does not match the file's first bytes, fails with `reasonCode` `INVALID_FILE`.
1022
+ */
1023
+ attachEvidence(purchaseId: string, file: Blob, filename: string): Promise<{
1024
+ id: string;
1025
+ matchStatus: string;
1026
+ }>;
1027
+ }
1028
+ declare class AdminSpendingClient {
1029
+ private client;
1030
+ constructor(client: SpendingRequester);
1031
+ /**
1032
+ * CSV of the organization's purchases against shared budgets. Fails with `reasonCode`
1033
+ * `EXPORT_TOO_LARGE` above 10,000 purchases.
1034
+ */
1035
+ exportPurchases(): Promise<DownloadBytes>;
1036
+ /**
1037
+ * Attach a PDF, PNG or JPEG of at most 2 MiB, with up to 10 files per purchase. Set the Blob's
1038
+ * `type` to `application/pdf`, `image/png` or `image/jpeg`. A Blob with no type, or with a type
1039
+ * that does not match the file's first bytes, fails with `reasonCode` `INVALID_FILE`.
1040
+ */
1041
+ attachEvidence(purchaseId: string, file: Blob, filename: string): Promise<{
1042
+ id: string;
1043
+ matchStatus: string;
1044
+ }>;
1045
+ downloadEvidence(purchaseId: string, evidenceId: string): Promise<DownloadBytes>;
1046
+ budgets(): Promise<{
1047
+ snapshotAt: string;
1048
+ timezone: string;
1049
+ budgets: BudgetSnapshot[];
1050
+ buyerConnection?: {
1051
+ revoked: boolean;
1052
+ participantId: string;
1053
+ };
1054
+ }>;
1055
+ /**
1056
+ * Create a shared budget. Needs an organization API key with `policies:write`.
1057
+ *
1058
+ * While a budget exists, it stops x402, MPP, external wallet payments, agent-to-agent payments,
1059
+ * payment grants, checkout relay, hosted Stripe Link, guarded browser checkout
1060
+ * (`runGuardedCheckout()`), card overlays and checkout checkpoints, including
1061
+ * `checkout.getLinkCard()`, for every agent it covers. A paused, expired or not yet started budget
1062
+ * still stops them. Until its start date, while paused, and after its end date, it also refuses
1063
+ * the managed wallet payments and connected card draws it covers, for those agents. A start date
1064
+ * cannot be changed.
1065
+ * `deleteBudget()` ends a budget. Fails with `reasonCode`
1066
+ * `ENROLLMENT_RECONCILIATION_REQUIRED` while the organization or a participating agent has an
1067
+ * open commitment.
1068
+ */
1069
+ createBudget(input: BudgetInput): Promise<{
1070
+ id: string;
1071
+ version: number;
1072
+ }>;
1073
+ /**
1074
+ * Change a budget's amount or active state, or move its end date to a later time in the future.
1075
+ * Needs the budget's current `version`. A task budget can only change its active state. Pausing
1076
+ * stops new purchases on it, and does not lift what it stops on other payment paths.
1077
+ */
1078
+ updateBudget(budgetId: string, input: {
1079
+ version: number;
1080
+ amount?: string;
1081
+ isActive?: boolean;
1082
+ periodEnd?: string;
1083
+ }): Promise<{
1084
+ id: string;
1085
+ version: number;
1086
+ }>;
1087
+ /**
1088
+ * End a budget, so it stops applying on every path. Needs the budget's current `version`. Fails
1089
+ * with `reasonCode` `BUDGET_HAS_HOLDS` while a purchase holds spend against it, and `TASK_BUDGET`
1090
+ * for a task's budget, which ends by closing the task. A linked buyer with no budget left fails
1091
+ * with `reasonCode` `LINKED_BUDGET_REQUIRED`.
1092
+ */
1093
+ deleteBudget(budgetId: string, input: {
1094
+ version: number;
1095
+ }): Promise<{
1096
+ id: string;
1097
+ deleted: true;
1098
+ }>;
1099
+ tasks(cursor?: string): Promise<{
1100
+ tasks: TaskSnapshot[];
1101
+ nextCursor: string | null;
1102
+ }>;
1103
+ /** Approve, reject or close a task. Needs an organization API key with `policies:write`. */
1104
+ decideTask(taskId: string, input: {
1105
+ decision: 'APPROVE' | 'REJECT' | 'CLOSE';
1106
+ amount?: string;
1107
+ participantIds?: string[];
1108
+ }): Promise<{
1109
+ id: string;
1110
+ status: string;
1111
+ }>;
1112
+ purchases(cursor?: string): Promise<{
1113
+ purchases: PurchaseSnapshot[];
1114
+ nextCursor: string | null;
1115
+ }>;
1116
+ purchase(purchaseId: string): Promise<PurchaseDetail>;
1117
+ /** Record what happened to a purchase. Needs an API key with the `spending:reconcile` scope. */
1118
+ reconcile(purchaseId: string, input: {
1119
+ eventKey: string;
1120
+ kind: 'RELEASED' | 'SETTLED' | 'REFUNDED' | 'UNKNOWN';
1121
+ settledAmount?: string;
1122
+ refundedAmount?: string;
1123
+ final?: boolean;
1124
+ evidenceRef: string;
1125
+ }): Promise<PurchaseSnapshot | null>;
1126
+ accounting(purchaseId: string, input: {
1127
+ department: string | null;
1128
+ project: string | null;
1129
+ accountingCode: string | null;
1130
+ }): Promise<{
1131
+ id: string;
1132
+ department: string | null;
1133
+ project: string | null;
1134
+ accountingCode: string | null;
1135
+ }>;
1136
+ /** Record the amount, currency and merchant on a file. Conto does not take them from the file. */
1137
+ reviewEvidence(purchaseId: string, evidenceId: string, input: {
1138
+ amount: string;
1139
+ currency: string;
1140
+ merchant: string;
1141
+ }): Promise<{
1142
+ id: string;
1143
+ matchStatus: string;
1144
+ }>;
1145
+ }
1146
+
842
1147
  interface ApiErrorMetadata {
843
1148
  code: string;
844
1149
  status: number;
@@ -851,6 +1156,8 @@ interface ApiErrorMetadata {
851
1156
  message: string;
852
1157
  }>;
853
1158
  reasons?: string[];
1159
+ reasonCode?: string;
1160
+ nextActions?: string[];
854
1161
  }
855
1162
 
856
1163
  /**
@@ -894,6 +1201,9 @@ declare class ContoAdminError extends Error {
894
1201
  readonly requestId?: string;
895
1202
  readonly retryAfter?: number;
896
1203
  readonly retryGuidance?: string;
1204
+ readonly reasonCode?: string;
1205
+ readonly nextActions?: string[];
1206
+ readonly fieldErrors?: ApiErrorMetadata['fieldErrors'];
897
1207
  constructor(message: string, metadata: ApiErrorMetadata);
898
1208
  }
899
1209
  interface PaginationParams {
@@ -1506,6 +1816,7 @@ declare class ContoAdmin {
1506
1816
  #private;
1507
1817
  private baseUrl;
1508
1818
  private timeout;
1819
+ spending: AdminSpendingClient;
1509
1820
  agents: AgentsClient;
1510
1821
  wallets: WalletsClient;
1511
1822
  cards: AdminCardsClient;
@@ -1523,11 +1834,16 @@ declare class ContoAdmin {
1523
1834
  signal?: AbortSignal;
1524
1835
  lastEventId?: string;
1525
1836
  }): Promise<Response>;
1837
+ /**
1838
+ * Download a file from the Conto API as bytes. It retries like a read, and
1839
+ * failures throw ContoAdminError as request() does.
1840
+ */
1841
+ download(path: string): Promise<DownloadBytes>;
1526
1842
  /**
1527
1843
  * Make an authenticated request to the Conto API. Reads retry. A write retries
1528
1844
  * only when `idempotent` says the API deduplicates it, as purchase creation does.
1529
1845
  */
1530
- request<T>(method: string, path: string, body?: Record<string, unknown>, options?: {
1846
+ request<T>(method: string, path: string, body?: Record<string, unknown> | FormData, options?: {
1531
1847
  idempotent?: boolean;
1532
1848
  }): Promise<T>;
1533
1849
  }
@@ -1858,6 +2174,13 @@ interface PaymentRequestInput {
1858
2174
  currency?: string;
1859
2175
  dueDate?: string;
1860
2176
  };
2177
+ /** An approved shared budget task, from `conto.spending.requestTask()`. */
2178
+ taskRequestId?: string;
2179
+ /**
2180
+ * A stable id for this purchase against shared budgets. A key cannot be used again, even after
2181
+ * its purchase is released, so use a new key for a new attempt.
2182
+ */
2183
+ purchaseKey?: string;
1861
2184
  };
1862
2185
  /** Specific wallet ID to use (optional) */
1863
2186
  walletId?: string;
@@ -2023,7 +2346,8 @@ interface ExternalWalletApprovalInput {
2023
2346
  recipientName?: string;
2024
2347
  purpose?: string;
2025
2348
  category?: string;
2026
- context?: PaymentRequestInput['context'];
2349
+ /** A self-custody wallet cannot pay against a shared task, so the task fields are refused. */
2350
+ context?: Omit<NonNullable<PaymentRequestInput['context']>, 'taskRequestId' | 'purchaseKey'>;
2027
2351
  }
2028
2352
  interface ExternalWalletApprovalResult {
2029
2353
  approved: boolean;
@@ -2326,6 +2650,10 @@ interface ConnectedCardDrawInput {
2326
2650
  /** Only USD is supported. Defaults to USD. */
2327
2651
  currency?: 'USD';
2328
2652
  merchant: ConnectedCardDrawMerchant;
2653
+ /** Why the agent wants this purchase, up to 500 characters. Shown to the person reviewing it. */
2654
+ purpose?: string;
2655
+ /** An approved task, for a budget that requires one. Naming a task grants nothing. */
2656
+ taskRequestId?: string;
2329
2657
  }
2330
2658
  /**
2331
2659
  * Live single-use card material returned by {@link ConnectedCardsClient.draw}.
@@ -2355,6 +2683,8 @@ interface ConnectedCardDrawResult {
2355
2683
  replayed: boolean;
2356
2684
  decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
2357
2685
  reasons: string[];
2686
+ /** Present when a budget refused the draw, for example `TASK_REQUIRED`. */
2687
+ reasonCodes?: string[];
2358
2688
  /** Present when the draw outcome is ambiguous and needs reconciliation. */
2359
2689
  reconciliationRequired?: boolean;
2360
2690
  /**
@@ -2454,6 +2784,8 @@ interface TestCardDrawResult {
2454
2784
  replayed: boolean;
2455
2785
  decision: 'APPROVED' | 'DENIED' | 'REQUIRES_APPROVAL';
2456
2786
  reasons: string[];
2787
+ /** Present when a budget refused the draw, for example `TASK_REQUIRED`. */
2788
+ reasonCodes?: string[];
2457
2789
  reconciliationRequired?: boolean;
2458
2790
  /** Present only on the response that issues it. A replay never returns it again. */
2459
2791
  testCredential?: TestCardCredential;
@@ -2585,7 +2917,10 @@ interface ConfirmCheckoutCheckpointInput {
2585
2917
  currency?: 'USD';
2586
2918
  /** Observed final items. Supplied items are checked even when the total is unchanged. */
2587
2919
  lineItems?: CommerceLineItemInput[];
2588
- /** Observed final charges. Supplied charges are checked even when the total is unchanged. */
2920
+ /**
2921
+ * Observed final charges, such as subtotal, tax and shipping. Conto checks that the final
2922
+ * total matches. The other rows may differ from the ones passed to begin().
2923
+ */
2589
2924
  totals?: CommerceTotalInput[];
2590
2925
  /** Page where the payment is submitted: the merchant's site or the payment method's. */
2591
2926
  pageUrl?: string;
@@ -2626,6 +2961,12 @@ interface CheckoutCheckpoint {
2626
2961
  outcomeReference?: string;
2627
2962
  /** The payment your checkout reported at confirm or outcome, such as a Link spend request. */
2628
2963
  paymentReference?: CheckoutPaymentReference;
2964
+ /**
2965
+ * True when the checkpoint stopped before its confirm while its Link request may still work, so
2966
+ * the stage is OUTCOME_UNKNOWN. Cancel the Link request, then cancel the checkpoint. Absent on a
2967
+ * confirmed checkpoint with no outcome, whose card may be in use: report the outcome instead.
2968
+ */
2969
+ linkRequestOpen?: true;
2629
2970
  /** Outcomes are reported by your checkout. Conto does not verify settlement here. */
2630
2971
  settlementVerified: false;
2631
2972
  }
@@ -3338,6 +3679,8 @@ declare class ContoError extends Error {
3338
3679
  readonly actionUrl?: string;
3339
3680
  readonly fieldErrors?: ApiErrorMetadata['fieldErrors'];
3340
3681
  readonly reasons?: string[];
3682
+ readonly reasonCode?: string;
3683
+ readonly nextActions?: string[];
3341
3684
  readonly diagnostics?: SetupDiagnostics;
3342
3685
  constructor(message: string, metadata: ApiErrorMetadata, diagnostics?: unknown);
3343
3686
  }
@@ -3404,9 +3747,8 @@ declare class CheckoutApprovalTimeoutError extends ContoError {
3404
3747
  constructor(checkpoint: CheckoutCheckpoint);
3405
3748
  }
3406
3749
  /**
3407
- * getLinkCard() or replaceLinkCard() stopped after Conto approved the purchase.
3408
- * No card was returned. Conto cancelled the checkpoint to release the held
3409
- * spend unless holdReleased is false. Do not pay.
3750
+ * getLinkCard() or replaceLinkCard() stopped, and no card was returned. Do not
3751
+ * pay. Follow retryGuidance, which depends on the code and the stage.
3410
3752
  */
3411
3753
  declare class LinkCardError extends ContoError {
3412
3754
  readonly checkpoint: CheckoutCheckpoint;
@@ -3414,11 +3756,16 @@ declare class LinkCardError extends ContoError {
3414
3756
  /**
3415
3757
  * The Stripe Link page where the person could approve the request, set when
3416
3758
  * the SDK stopped while the request was waiting for them. It works only while
3417
- * the request is still open in Link. When holdReleased is true, Conto has
3418
- * already cancelled the request.
3759
+ * the request is still open in Link. With LINK_CARD_NOT_CANCELLED it is set
3760
+ * only when a retry can resume the request. With any other code, the request
3761
+ * is already closed.
3419
3762
  */
3420
3763
  readonly approvalUrl?: string;
3421
- /** True when Conto cancelled the checkpoint and released the held spend. */
3764
+ /**
3765
+ * True when the checkpoint no longer holds the spend. It says nothing about
3766
+ * the card. With LINK_CARD_NOT_CANCELLED, LINK_CARD_NOT_REPLACED or
3767
+ * LINK_CARD_ABORTED, a card may still work.
3768
+ */
3422
3769
  readonly holdReleased: boolean;
3423
3770
  constructor(input: {
3424
3771
  message: string;
@@ -3458,6 +3805,7 @@ declare class Conto {
3458
3805
  private timeout;
3459
3806
  /** Lightweight checkpoints before the payment method opens and before payment. */
3460
3807
  checkout: CheckoutClient;
3808
+ spending: SpendingClient;
3461
3809
  payments: PaymentsClient;
3462
3810
  cards: CardsClient;
3463
3811
  connectedCards: ConnectedCardsClient;
@@ -3555,8 +3903,13 @@ declare class Conto {
3555
3903
  signal?: AbortSignal;
3556
3904
  lastEventId?: string;
3557
3905
  }): Promise<Response>;
3906
+ /**
3907
+ * Download a file from the Conto API as bytes. It retries like a read, and
3908
+ * failures throw ContoError as request() does.
3909
+ */
3910
+ download(path: string): Promise<DownloadBytes>;
3558
3911
  /** Make an authenticated request to the Conto API */
3559
- request<T>(method: string, path: string, body?: Record<string, unknown>, options?: ContoRequestOptions): Promise<T>;
3912
+ request<T>(method: string, path: string, body?: Record<string, unknown> | FormData, options?: ContoRequestOptions): Promise<T>;
3560
3913
  }
3561
3914
  /** Agent client for the cooperative external-card policy overlay. */
3562
3915
  declare class CardsClient {
@@ -3881,7 +4234,9 @@ declare class CheckoutClient {
3881
4234
  reportOutcome(checkpointId: string, input: ReportCheckoutOutcomeInput): Promise<CheckoutCheckpoint>;
3882
4235
  /**
3883
4236
  * Cancel a checkpoint that was not confirmed and release its spend. A
3884
- * checkpoint waiting for the owner can be cancelled too.
4237
+ * checkpoint waiting for the owner can be cancelled too. This does not close
4238
+ * a Link card, which can still work with nothing held behind it, so cancel
4239
+ * the Link request first.
3885
4240
  */
3886
4241
  cancel(checkpointId: string): Promise<CheckoutCheckpoint>;
3887
4242
  get(checkpointId: string): Promise<CheckoutCheckpoint>;
@@ -3893,9 +4248,10 @@ declare class CheckoutClient {
3893
4248
  * 1. Conto runs checkpoint 1 and holds the spend. When a rule requires the
3894
4249
  * owner's approval, this waits for it.
3895
4250
  * 2. Only then does the wallet ask Link for a card for exactly the approved
3896
- * amount at this merchant. The person approves it in Link. Pass
3897
- * onLinkApproval to get Link's approval page, so they can approve on the
3898
- * web without the Link app.
4251
+ * amount at this merchant. Conto records the Link request at once, so the
4252
+ * hold stays while the card may be usable. The person approves it in
4253
+ * Link. Pass onLinkApproval to get Link's approval page, so they can
4254
+ * approve on the web without the Link app.
3899
4255
  * 3. The card is returned. It never reaches Conto.
3900
4256
  *
3901
4257
  * Then fill in the card, call confirm(result.checkpoint, { amountMinor,
@@ -3908,17 +4264,25 @@ declare class CheckoutClient {
3908
4264
  * held spend and throws a LinkCardError. When Conto cannot cancel an open Link
3909
4265
  * request, it keeps the hold and throws LINK_CARD_NOT_CANCELLED with the
3910
4266
  * request id. Retrying with the same input resumes the same checkpoint and
3911
- * Link request.
4267
+ * Link request while Conto's approval is open. If its approval ended with the
4268
+ * request open, a retry throws CHECKOUT_CHECKPOINT_NOT_APPROVED. Cancel the Link
4269
+ * request, then the checkpoint. Once a confirm has started, a retry throws
4270
+ * LINK_CARD_NOT_ISSUED. Do not cancel the Link request while a payment may be in
4271
+ * flight. Follow error.retryGuidance, which depends on the stage.
3912
4272
  */
3913
4273
  getLinkCard(input: GetLinkCardInput): Promise<LinkCardResult>;
3914
4274
  /**
3915
4275
  * The final total differs from the one the Link card covers. This cancels
3916
4276
  * the old Link request and checkpoint, begins a checkpoint at the final
3917
4277
  * total (waiting for the owner when a rule requires it), and gets a new card
3918
- * for it. Confirm the returned checkpoint with the same total.
4278
+ * for it. Confirm the returned checkpoint with the same total. It reads the
4279
+ * checkpoint first. At a stage where a payment may be in flight, or with a
4280
+ * different Link request on record, this throws LINK_CARD_NOT_REPLACED and
4281
+ * leaves the card and the hold alone. After the old card is closed, trying
4282
+ * again with the same input resumes the replacement.
3919
4283
  */
3920
4284
  replaceLinkCard(previous: LinkCardResult, input: ReplaceLinkCardInput): Promise<LinkCardResult>;
3921
4285
  }
3922
4286
 
3923
- export { AdminPurchasingClient, BrowserActionFinalizationPendingError, BrowserCheckoutTargetVerificationError, CardsClient, CheckoutApprovalDeniedError, CheckoutApprovalExpiredError, CheckoutApprovalPendingError, CheckoutApprovalTimeoutError, CheckoutCheckpointClosedError, CheckoutClient, ConnectedCardsClient, Conto, ContoAdmin, ContoAdminError, ContoError, ControlledExternalCardPaymentTool, ExternalCardConfirmationPendingError, Conto as Giro, ContoError as GiroError, LinkCardCredential, LinkCardDeniedError, LinkCardError, LinkCardExpiredError, LinkCardTimeoutError, LinkWallet, LinkWalletUnavailableError, OrganizationPurchasesClient, OrganizationRecurringPurchasesClient, PurchasesClient, RecurringPurchasesClient, TestCardsClient, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget, isFinalPurchaseStatus, parseServerSentEvents, verifyPurchaseWebhook };
3924
- export type { AdminExternalCardOverlayEnforcement, Agent, AgentCheckoutAction, AgentCheckoutActionKind, AgentExternalCard, AgentSetupResult, AgentStatus, AgentType, AgentWalletLink, ApprovedExternalCardExecution, AssignExternalCardInput, AssignedPolicy, AuthorizeCheckoutActionResult, BeginCheckoutCheckpointInput, BeginCommerceExecutionInput, BrowserActionClaimResult, BrowserActionDispatchObservationInput, BrowserActionFinalizeResult, BrowserCheckoutAction, BrowserCheckoutTargetResolver, BrowserCheckoutTargetSnapshot, BrowserCheckoutTargetVerificationCode, CancellationOutcome, CanonicalBrowserCheckoutTargetSnapshot, ChainType, CheckoutActionAuthorization, CheckoutCheckpoint, CheckoutCheckpointApproval, CheckoutCheckpointMethod, CheckoutCheckpointNextAction, CheckoutCheckpointStage, CheckoutOutcome, CheckoutPaymentReference, CommerceCheckoutMethod, CommerceContextRequirement, CommerceExecution, CommerceExecutionAdapterKind, CommerceExecutionArtifactKind, CommerceExecutionChannel, CommerceExecutionConstraint, CommerceExecutionConstraintCoverage, CommerceExecutionConstraintCoverageLevel, CommerceExecutionDeliveryMode, CommerceExecutionEvidence, CommerceExecutionProvider, CommerceExecutionResult, CommerceExecutionSourceKind, CommerceExecutionStatus, CommerceFactConfidence, CommerceFactProvenanceInput, CommerceFactSource, CommerceFulfillmentInput, CommerceLineItemInput, CommerceProposalFactKey, CommerceProposalMissingFact, CommerceProposalResolution, CommerceProposalState, CommerceSettlementRail, CommerceTotalInput, CommerceTotalType, ComparePolicyVersionsResponse, ConfirmCheckoutCheckpointInput, ConnectedCardBrief, ConnectedCardCredential, ConnectedCardDrawInput, ConnectedCardDrawMerchant, ConnectedCardDrawResult, ConnectedCardDrawable, ConnectedCardListResult, ConnectedCardMandate, ConnectedCardMandateMerchant, ConnectedCardOutcomeReport, ConnectedCardOutcomeReportResult, ConnectedCardReference, ContoAdminConfig, ContoConfig, ContoRequestOptions, ControlledExternalCardPaymentResult, CreateAgentInput, CreatePolicyInput, CreatePolicyRuleInput, CreatePurchaseInput, CreateSdkKeyInput, CreateSdkKeyResult, CreateWalletInput, CustodyType, CustomerCustodyMode, CustomerWalletControlModel, CustomerWalletKeyAccess, DelegationType, ExecuteCommerceExecutionResult, ExternalCard, ExternalCardApprovalInput, ExternalCardApprovalResult, ExternalCardConfirmationInput, ExternalCardConfirmationResult, ExternalCardExecutionClaimResult, ExternalCardExecutionResult, ExternalCardExecutor, ExternalCardOverlayEnforcement, ExternalCardRequestStatusResult, ExternalWalletApprovalInput, ExternalWalletApprovalResult, ExternalWalletConfirmationInput, ExternalWalletConfirmationResult, FreezeAgentInput, GetLinkCardInput, ContoConfig as GiroConfig, GuardCheckoutResult, GuardedBrowserDispatchResult, GuardedCheckoutInput, LinkApprovalCallback, LinkApprovalEvent, LinkCardResult, LinkWalletInput, ListAgentsParams, ListAgentsResponse, ListPoliciesParams, ListPoliciesResponse, ListPolicyVersionsResponse, ListWalletsParams, ListWalletsResponse, MppBudgetResult, MppPreAuthorizeInput, MppPreAuthorizeResult, MppRecordInput, MppRecordResult, NormalizeCommerceProposalInput, OrganizationMember, PaginatedResponse, PaginationParams, PauseExternalCardAssignmentResult, PaymentExecuteResult, PaymentRequestInput, PaymentRequestResult, PaymentStatusResult, Policy, PolicyRule, PolicyType, PolicyVersionChangeType, PolicyVersionDetail, PolicyVersionDiff, PolicyVersionFieldChange, PolicyVersionSnapshot, PolicyVersionSnapshotRule, PolicyVersionSummary, PrivilegedBrowserCheckoutDriver, ProtocolBudgetResult, ProtocolPreAuthorizeResult, ProtocolRecordGrant, ProtocolRecordGrantResult, ProtocolServiceSummary, ProtocolServicesResult, ProveWalletOwnershipInput, ProvisionWalletResult, Purchase, PurchaseAction, PurchaseActionAuthority, PurchaseActionKind, PurchaseAllowance, PurchaseBuyer, PurchaseBuyerCompanyCard, PurchaseBuyerCompanyCardLimits, PurchaseBuyerKitchenContext, PurchaseCompanyCard, PurchaseDelegation, PurchaseEvent, PurchaseEventPage, PurchaseEvidence, PurchaseGrocery, PurchaseGroceryItem, PurchaseGroceryList, PurchaseHostedLink, PurchaseItem, PurchaseKitchenContext, PurchaseKitchenInventoryItem, PurchaseKitchenListItem, PurchaseKitchenPreferences, PurchaseKitchenRecipe, PurchaseKitchenUsual, PurchaseList, PurchaseMoney, PurchasePaymentMethod, PurchasePhase, PurchaseRequest, PurchaseResponseAck, PurchaseStatus, PurchasingCapabilities, PurchasingSettings, RecurringPurchase, RecurringPurchaseCycleResult, RecurringPurchaseCycleStatus, RefreshBalanceResult, RegisterExternalCardInput, ReplaceLinkCardInput, ReportCheckoutOutcomeInput, RollbackPolicyVersionResponse, RuleAction, RuleOperator, RuleType, RunGuardedCheckoutResult, SdkKey, SdkKeyType, SetupCapabilityState, SetupCardDiagnostics, SetupDiagnosticAction, SetupDiagnosticIssue, SetupDiagnosticIssueCode, SetupDiagnostics, SetupWalletDiagnostics, TestCardCredential, TestCardDrawResult, TestCardDrawable, TestCardListResult, TestCardReceipt, TestCheckoutInput, TestCheckoutResult, TestMerchant, TestMerchantProduct, UnfreezeAgentInput, UpdateAgentInput, UpdateExternalCardAssignmentInput, UpdatePolicyInput, UpdatePolicyRuleInput, UpdateWalletInput, VerifiedBrowserCheckoutTarget, WaitForCheckoutApprovalOptions, Wallet, WalletChainBalanceSnapshot, WalletOwnershipChallenge, WalletOwnershipProof, WalletStatus, WalletType, WatchPurchaseOptions, X402Authorization, X402BudgetResult, X402PayInput, X402PayResult, X402PaymentRequirements, X402PreAuthorizeInput, X402PreAuthorizeResult, X402RecordInput, X402RecordResult };
4287
+ export { AdminPurchasingClient, AdminSpendingClient, BrowserActionFinalizationPendingError, BrowserCheckoutTargetVerificationError, CardsClient, CheckoutApprovalDeniedError, CheckoutApprovalExpiredError, CheckoutApprovalPendingError, CheckoutApprovalTimeoutError, CheckoutCheckpointClosedError, CheckoutClient, ConnectedCardsClient, Conto, ContoAdmin, ContoAdminError, ContoError, ControlledExternalCardPaymentTool, ExternalCardConfirmationPendingError, Conto as Giro, ContoError as GiroError, LinkCardCredential, LinkCardDeniedError, LinkCardError, LinkCardExpiredError, LinkCardTimeoutError, LinkWallet, LinkWalletUnavailableError, OrganizationPurchasesClient, OrganizationRecurringPurchasesClient, PurchasesClient, RecurringPurchasesClient, SpendingClient, TestCardsClient, canonicalizeBrowserCheckoutTarget, createVerifiedBrowserCheckoutDriver, Conto as default, fingerprintBrowserCheckoutTarget, isFinalPurchaseStatus, parseServerSentEvents, verifyPurchaseWebhook };
4288
+ export type { AdminExternalCardOverlayEnforcement, Agent, AgentCheckoutAction, AgentCheckoutActionKind, AgentExternalCard, AgentSetupResult, AgentStatus, AgentType, AgentWalletLink, ApprovedExternalCardExecution, AssignExternalCardInput, AssignedPolicy, AuthorizeCheckoutActionResult, BeginCheckoutCheckpointInput, BeginCommerceExecutionInput, BrowserActionClaimResult, BrowserActionDispatchObservationInput, BrowserActionFinalizeResult, BrowserCheckoutAction, BrowserCheckoutTargetResolver, BrowserCheckoutTargetSnapshot, BrowserCheckoutTargetVerificationCode, BudgetInput, BudgetSnapshot, CancellationOutcome, CanonicalBrowserCheckoutTargetSnapshot, ChainType, CheckoutActionAuthorization, CheckoutCheckpoint, CheckoutCheckpointApproval, CheckoutCheckpointMethod, CheckoutCheckpointNextAction, CheckoutCheckpointStage, CheckoutOutcome, CheckoutPaymentReference, CommerceCheckoutMethod, CommerceContextRequirement, CommerceExecution, CommerceExecutionAdapterKind, CommerceExecutionArtifactKind, CommerceExecutionChannel, CommerceExecutionConstraint, CommerceExecutionConstraintCoverage, CommerceExecutionConstraintCoverageLevel, CommerceExecutionDeliveryMode, CommerceExecutionEvidence, CommerceExecutionProvider, CommerceExecutionResult, CommerceExecutionSourceKind, CommerceExecutionStatus, CommerceFactConfidence, CommerceFactProvenanceInput, CommerceFactSource, CommerceFulfillmentInput, CommerceLineItemInput, CommerceProposalFactKey, CommerceProposalMissingFact, CommerceProposalResolution, CommerceProposalState, CommerceSettlementRail, CommerceTotalInput, CommerceTotalType, ComparePolicyVersionsResponse, ConfirmCheckoutCheckpointInput, ConnectedCardBrief, ConnectedCardCredential, ConnectedCardDrawInput, ConnectedCardDrawMerchant, ConnectedCardDrawResult, ConnectedCardDrawable, ConnectedCardListResult, ConnectedCardMandate, ConnectedCardMandateMerchant, ConnectedCardOutcomeReport, ConnectedCardOutcomeReportResult, ConnectedCardReference, ContoAdminConfig, ContoConfig, ContoRequestOptions, ControlledExternalCardPaymentResult, CreateAgentInput, CreatePolicyInput, CreatePolicyRuleInput, CreatePurchaseInput, CreateSdkKeyInput, CreateSdkKeyResult, CreateWalletInput, CustodyType, CustomerCustodyMode, CustomerWalletControlModel, CustomerWalletKeyAccess, DelegationType, DownloadBytes, ExecuteCommerceExecutionResult, ExternalCard, ExternalCardApprovalInput, ExternalCardApprovalResult, ExternalCardConfirmationInput, ExternalCardConfirmationResult, ExternalCardExecutionClaimResult, ExternalCardExecutionResult, ExternalCardExecutor, ExternalCardOverlayEnforcement, ExternalCardRequestStatusResult, ExternalWalletApprovalInput, ExternalWalletApprovalResult, ExternalWalletConfirmationInput, ExternalWalletConfirmationResult, FreezeAgentInput, GetLinkCardInput, ContoConfig as GiroConfig, GuardCheckoutResult, GuardedBrowserDispatchResult, GuardedCheckoutInput, LinkApprovalCallback, LinkApprovalEvent, LinkCardResult, LinkWalletInput, ListAgentsParams, ListAgentsResponse, ListPoliciesParams, ListPoliciesResponse, ListPolicyVersionsResponse, ListWalletsParams, ListWalletsResponse, MppBudgetResult, MppPreAuthorizeInput, MppPreAuthorizeResult, MppRecordInput, MppRecordResult, NormalizeCommerceProposalInput, OrganizationMember, PaginatedResponse, PaginationParams, PauseExternalCardAssignmentResult, PaymentExecuteResult, PaymentRequestInput, PaymentRequestResult, PaymentStatusResult, Policy, PolicyRule, PolicyType, PolicyVersionChangeType, PolicyVersionDetail, PolicyVersionDiff, PolicyVersionFieldChange, PolicyVersionSnapshot, PolicyVersionSnapshotRule, PolicyVersionSummary, PreviewInput, PrivilegedBrowserCheckoutDriver, ProtocolBudgetResult, ProtocolPreAuthorizeResult, ProtocolRecordGrant, ProtocolRecordGrantResult, ProtocolServiceSummary, ProtocolServicesResult, ProveWalletOwnershipInput, ProvisionWalletResult, Purchase, PurchaseAction, PurchaseActionAuthority, PurchaseActionKind, PurchaseAllowance, PurchaseBuyer, PurchaseBuyerCompanyCard, PurchaseBuyerCompanyCardLimits, PurchaseBuyerKitchenContext, PurchaseCompanyCard, PurchaseDelegation, PurchaseDetail, PurchaseEvent, PurchaseEventPage, PurchaseEvidence, PurchaseGrocery, PurchaseGroceryItem, PurchaseGroceryList, PurchaseHostedLink, PurchaseItem, PurchaseKitchenContext, PurchaseKitchenInventoryItem, PurchaseKitchenListItem, PurchaseKitchenPreferences, PurchaseKitchenRecipe, PurchaseKitchenUsual, PurchaseList, PurchaseMoney, PurchasePaymentMethod, PurchasePhase, PurchaseRequest, PurchaseResponseAck, PurchaseSnapshot, PurchaseStatus, PurchasingCapabilities, PurchasingSettings, RecurringPurchase, RecurringPurchaseCycleResult, RecurringPurchaseCycleStatus, RefreshBalanceResult, RegisterExternalCardInput, ReplaceLinkCardInput, ReportCheckoutOutcomeInput, RollbackPolicyVersionResponse, RuleAction, RuleOperator, RuleType, RunGuardedCheckoutResult, SdkKey, SdkKeyType, SetupCapabilityState, SetupCardDiagnostics, SetupDiagnosticAction, SetupDiagnosticIssue, SetupDiagnosticIssueCode, SetupDiagnostics, SetupWalletDiagnostics, SpendingRequester, TaskInput, TaskSnapshot, TestCardCredential, TestCardDrawResult, TestCardDrawable, TestCardListResult, TestCardReceipt, TestCheckoutInput, TestCheckoutResult, TestMerchant, TestMerchantProduct, UnfreezeAgentInput, UpdateAgentInput, UpdateExternalCardAssignmentInput, UpdatePolicyInput, UpdatePolicyRuleInput, UpdateWalletInput, VerifiedBrowserCheckoutTarget, WaitForCheckoutApprovalOptions, Wallet, WalletChainBalanceSnapshot, WalletOwnershipChallenge, WalletOwnershipProof, WalletStatus, WalletType, WatchPurchaseOptions, X402Authorization, X402BudgetResult, X402PayInput, X402PayResult, X402PaymentRequirements, X402PreAuthorizeInput, X402PreAuthorizeResult, X402RecordInput, X402RecordResult };