Skip to main content
PATCH
/
api
/
v1
/
agreement
/
{agreementId}
Update agreement
curl --request PATCH \
  --url https://demo.api.loopcrypto.xyz/api/v1/agreement/{agreementId} \
  --header 'Content-Type: application/json' \
  --header 'api-key: <api-key>' \
  --header 'entity-id: <api-key>' \
  --data '{
  "wallet": "0xfc667b40851c3b1E50b31A8E9a206fa7934aCf64",
  "token": {
    "networkId": 123,
    "address": "<string>"
  },
  "status": "Canceled",
  "emailAddress": "user@example.com",
  "allowCancel": true,
  "allowResubscribe": true
}'
{
  "agreementId": "83aac889-da5b-4432-ac51-b05cf3ae2aac",
  "walletAddress": "0x56be8cpbed39582aad0eaa6e8f2adb109152fb6c",
  "networkId": 137,
  "email": "testing@example.xyz",
  "entityId": "911492f7-688d-11ed-9618-06613fde562",
  "token": "0x07865c6E87B9F70255377e024ace6630C1Eaa37F",
  "itemId": "8199041b-a8c2-40ae-b90d-633d3eb59111",
  "startDate": 1672423318,
  "status": 2,
  "cancelledAt": 1672761102,
  "cancellationEffectiveDate": 1672761534,
  "cancellationReason": "Cancelled by entity",
  "refId": "user-42",
  "discountPercent": 42,
  "externalId": "sub_1ObTC0EsKlmFX3FHDjZnmim1",
  "externalReferenceId": "mySpecialReference",
  "cancellationSource": 3,
  "allowCancel": true,
  "allowResubscribe": true,
  "paymentMethod": {
    "paymentMethodId": "1234567890abcdef",
    "merchantId": "67e55044-10b1-426f-9247-bb680e5fe0c8",
    "paymentMethodName": "My Crypto Wallet",
    "active": true,
    "customer": {
      "customerId": "1234567890abcdef",
      "customerRefId": "1234567890abcdef"
    },
    "networkId": 1,
    "walletAddress": "0x1234567890abcdef",
    "isDefault": true,
    "token": {
      "symbol": "USDC",
      "tokenId": "123e4567-e89b-12d3-a456-426614174000",
      "address": "0x1234567890abcdef",
      "decimals": 6,
      "exchangeRates": [
        {
          "currency": "USD",
          "price": "10000",
          "provider": "CoinMarketCap",
          "timestamp": 1715731200
        }
      ]
    },
    "preAuthorization": {
      "balance": "100",
      "authorization": "49.9"
    },
    "dateCreated": 1716211200
  }
}

Authorizations

api-key
string
header
required
entity-id
string
header
required

Path Parameters

agreementId
string
required

Body

application/json
wallet
string

The wallet address to update the agreement to. This will update the wallet address used for future payments and invoice generation.

Example:

"0xfc667b40851c3b1E50b31A8E9a206fa7934aCf64"

token
object

The token and network ID to update the agreement to. This will update both the token address and network ID used for future payments.

status
enum<string>

The status to update the agreement to

Available options:
Canceled
emailAddress
string

The email address to update the agreement to. This will update the email address associated with the agreement and be used for notifications and communications.

Example:

"user@example.com"

allowCancel
boolean

(Optional) Whether the user is allowed to self cancel the agreement

Example:

true

allowResubscribe
boolean

(Optional) Whether the user is allowed to resubscribe to the agreement after it has been canceled

Example:

true

Response

Ok

agreementId
string
required

The unique identifier for the agreement

Example:

"83aac889-da5b-4432-ac51-b05cf3ae2aac"

walletAddress
string
required

The blockchain wallet address that funds will originate from

Example:

"0x56be8cpbed39582aad0eaa6e8f2adb109152fb6c"

networkId
number
required

The blockchain network ID the agreement is associated with

Possible values:

  • 1 (Ethereum)
  • 10 (Optimism)
  • 56 (BNB)
  • 137 (Polygon)
  • 8453 (Base)
  • 42220 (Celo)
  • 42161 (Arbitrum)
  • 900 (Solana)
  • 11155111 (Sepolia) - Only available for demo environment
  • 901 (Solana Devnet) - Only available on the demo environment
Example:

137

email
string | null
required

The email associated with the wallet

Example:

"testing@example.xyz"

entityId
string
required

The ID of the entity the agreement relates to

Example:

"911492f7-688d-11ed-9618-06613fde562"

token
string
required

The address of the ERC20 token authorized to be transferred

Example:

"0x07865c6E87B9F70255377e024ace6630C1Eaa37F"

itemId
string
required

The ID of the item the agreement relates to

Example:

"8199041b-a8c2-40ae-b90d-633d3eb59111"

startDate
number
required

Unix time in seconds that the record was created

Example:

1672423318

status
number
required

The current status of the agreement

Possible values:

  • 1 (New)
  • 2 (Active)
  • 3 (Canceled)
  • 4 (One time purchase)
  • 5 (Cancellation has been scheduled (will be canceled at the end of the current billing period))
Example:

2

cancelledAt
number | null
required

Unix time in seconds that the record was cancelled

Example:

1672761102

cancellationEffectiveDate
number | null
required

Unix time in seconds of the end of the agreement period

Example:

1672761534

cancellationReason
string | null
required

The reason the agreement was cancelled

Possible values:

  • Cancelled by entity
  • Cancelled by wallet holder
  • Cancelled by auto cancel
  • Cancelled by Stripe
  • Cancelled by Loop support
  • Cancelled by API call
  • Disconnected from Stripe
Example:

"Cancelled by entity"

refId
string | null
required

A custom reference ID that will be stored and returned via "SignedUp" and "Cancelled" webhooks

Example:

"user-42"

discountPercent
number | null
required

A percentage discount applied to the transfer amounts.

Example:

42

externalId
string | null
required

A Stripe or Chargebee Subscription ID

Example:

"sub_1ObTC0EsKlmFX3FHDjZnmim1"

externalReferenceId
string | null
required

A reference ID for the our users use

Example:

"mySpecialReference"

cancellationSource
number | null
required

Cancellation source that denotes where the cancellation request originated from

Possible values:

  • 1 (Loop Support)
  • 2 (Chargebee)
  • 3 (Stripe)
  • 4 (Company Dashboard)
  • 5 (Customer Portal)
  • 6 (API Call)
  • 7 (Auto Cancellation)
  • 8 (Legacy Cancellation)
Example:

3

allowCancel
boolean
required

Whether the user is allowed to self cancel the agreement via the customer portal

Example:

true

allowResubscribe
boolean
required

Whether the user is allowed to resubscribe to the agreement after it has been canceled via the customer portal

Example:

true

paymentMethod
object

The payment method type associated with this agreement

I