Skip to main content
POST
/
api
/
v1
/
agreements
Create agreement
curl --request POST \
  --url https://demo.api.loopcrypto.xyz/api/v1/agreements \
  --header 'Content-Type: application/json' \
  --header 'api-key: <api-key>' \
  --header 'entity-id: <api-key>' \
  --data '{
  "walletAddress": "<string>",
  "networkId": 1,
  "email": "test@mail.com",
  "entityId": "0x1234",
  "refId": "123-abc",
  "token": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
  "itemIds": [
    "02cdf48d-dfbb-49ff-8439-28eb254ad43d",
    "0431edda-0027-4d38-bde1-5f1ad7bb614a"
  ],
  "externalSubscriptionId": "cus_01234",
  "externalPriceIds": [
    "price_01234",
    "price_01235",
    "price_01236"
  ],
  "payNow": false,
  "allowCancel": true,
  "allowResubscribe": true
}'
{
  "agreements": [
    {
      "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

Body

application/json
walletAddress
string
required

The wallet address the agreement is for.

networkId
number
required

The network ID of the blockchain the checkout is being made on.

Example:

1

token
string
required

The token address used to pay at checkout.

Example:

"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"

itemIds
string[]
required

The id's of the item being checked out.

Example:
[
"02cdf48d-dfbb-49ff-8439-28eb254ad43d",
"0431edda-0027-4d38-bde1-5f1ad7bb614a"
]
email
string

(Optional) the email of the user making the checkout.

Example:

"test@mail.com"

entityId
string

(Optional) The ID of the entity the checkout is for. Only required if the checkout is for a child entity.

Example:

"0x1234"

refId
string

(Optional) External reference ID.

Example:

"123-abc"

externalSubscriptionId
string

(Optional) The id of the subscription in the external system. Will be used to link the subscription to the agreement.

Example:

"cus_01234"

externalPriceIds
string[]

(Optional) The ids of the prices in the external system. Will be used to link the items using external price ids to the agreement.

Example:
["price_01234", "price_01235", "price_01236"]
payNow
boolean

(Optional) If an open or draft invoice should be paid immediately and not wait for the bill date

Example:

false

allowCancel
boolean

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

Example:

true

allowResubscribe
boolean

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

Example:

true

Response

Ok

To get agreementIDs, you can use the “get agreements” endpoint to query all the wallets that have authorized your contract and their associated items.

agreements
object[]
required

A list of the returned agreements based on the request

I