Service provisioning after proposal completion

Learn how to automate the provisioning of a new customer's service when they complete the proposal.

In this guide, we will walk through how to set up an event webhook that will notify your provisioning system when a proposal is completed and the new subscription is created.

Prerequisites

  • A public endpoint must be available for Cacheflow to send the webhook to.

Create an event webhook

  1. Navigate to the Account Settings page.
  2. Click on the API tab within the Integrations and Connectors section.
  3. In the webhooks section, click Create webhook.
  4. Enter a name and the receiving endpoint URL for Cacheflow to send the webhook to. For this use case, the contract_updated event should be used. Click Submit.

You have now created the event webhook that will notify your provisioning system when a proposal has been completed and the new subscription is created.

Receive the webhook

The webhook will contain information such as the type of event, subscription id, and status.

Example webhook:

{
  "id": "2db1305e-5fc3-4d26-a169-d6ad5432cbdd",
  "eventType": "contract_updated",
  "referenceType": "contract",
  "fields": {
    "id": "2db1305e-5fc3-4d26-a169-d6ad5432cbdd",
    "updatedAt": "2023-03-23T15:11:49.944272861Z",
    "name": "Test Contract",
    "externalId": "external-5678",
    "status": "active"
  }
}

Retrieve subscription information

When the webhook is received, the next step is to get the information from Cacheflow that is required to provision the new customer's service. Use the id from the webhook to make a request to the GET /contracts/{id} endpoint in Cacheflow. This will return back the all the customer, subscription, and product information.

Example GET /contracts/{id} call:

GET /api/latest/data/contracts/[id] HTTP/1.1
Host: [yourdomain].api.getcacheflow.com
Authorization: Bearer [Bearer Token]

Response:

{
    "id": "2274ed9c-dc18-453c-b953-4d981ce00e38",
    "createdBy": "[email protected]",
    "updatedAt": "2023-02-17T14:54:58.988815Z",
    "updatedBy": "[email protected]",
    "contractNumber": "236",
    "buyer": {
        "id": "53eea6ea-997b-43cb-9e17-13e62a901bb0",
        "createdAt": "2023-01-17T15:42:55.471759Z",
        "createdBy": "[email protected]",
        "updatedAt": "2023-02-27T22:57:29.66922Z",
        "updatedBy": "[email protected]",
        "name": "Brex Inc.",
        "billingAddress": {
            "id": "f59e8be6-5518-4f60-8b8f-203cb4fe400f",
            "createdAt": "2023-02-27T22:57:29.667018Z",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-27T22:57:29.667021Z",
            "streetAddress": "50 W Broadway",
            "subAddress": "",
            "city": "Boston",
            "region": "MA",
            "postalCode": "02127",
            "country": "United States"
        },
        "shippingAddress": {
            "id": "6736e2b0-79d3-49c9-9ffc-3cc44f27e1a6",
            "createdAt": "2023-01-17T15:42:55.470579Z",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-27T22:57:29.668287Z",
            "updatedBy": "[email protected]",
            "streetAddress": "",
            "subAddress": "",
            "otherAddress": "",
            "city": "",
            "region": "",
            "postalCode": "",
            "country": ""
        },
        "deleted": false,
        "referenceType": "customer",
        "syncable": true
    },
    "startDate": "2022-12-05",
    "endDate": "2023-12-04",
    "name": "Brex Inc.",
    "termType": "month",
    "termQty": 12,
    "outstandingAmount": 72067857,
    "totalAmount": 72067857,
    "baseAmount": 72067857,
    "proposalNumber": "439",
    "status": "active",
    "billingPeriod": "year",
    "billingMethod": {
        "id": "c5ae0f39-5d54-449d-990b-eb7084d0b987",
        "createdAt": "2023-02-17T14:48:30.644311Z",
        "createdBy": "[email protected]",
        "updatedAt": "2023-02-17T14:48:30.644313Z",
        "name": "ach",
        "status": "active",
        "paymentType": "ach",
        "customer": {
            "id": "53eea6ea-997b-43cb-9e17-13e62a901bb0",
            "createdAt": "2023-01-17T15:42:55.471759Z",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-27T22:57:29.66922Z",
            "updatedBy": "[email protected]",
            "name": "Brex Inc.",
            "billingAddress": {
                "id": "f59e8be6-5518-4f60-8b8f-203cb4fe400f",
                "createdAt": "2023-02-27T22:57:29.667018Z",
                "createdBy": "[email protected]",
                "updatedAt": "2023-02-27T22:57:29.667021Z",
                "streetAddress": "50 W Broadway",
                "subAddress": "",
                "city": "Boston",
                "region": "MA",
                "postalCode": "02127",
                "country": "United States"
            },
            "shippingAddress": {
                "id": "6736e2b0-79d3-49c9-9ffc-3cc44f27e1a6",
                "createdAt": "2023-01-17T15:42:55.470579Z",
                "createdBy": "[email protected]",
                "updatedAt": "2023-02-27T22:57:29.668287Z",
                "updatedBy": "[email protected]",
                "streetAddress": "",
                "subAddress": "",
                "otherAddress": "",
                "city": "",
                "region": "",
                "postalCode": "",
                "country": ""
            },
            "deleted": false,
            "referenceType": "customer",
            "syncable": true
        },
        "paymentMethod": {
            "id": "a8e368e5-5d55-479e-9cc8-821d91d90058",
            "createdAt": "2022-11-23T18:53:06.547738Z",
            "createdBy": "[email protected]",
            "updatedAt": "2023-01-20T14:16:06.192054Z",
            "updatedBy": "[email protected]",
            "name": "ACH",
            "description": "Pay via bank",
            "enabled": true,
            "configured": true,
            "managed": false,
            "billingPeriods": [
                "quarter",
                "year",
                "month"
            ],
            "paymentType": "ach",
            "configuration": {
                "accountName": "JCBank",
                "bankName": "BankofJC",
                "routingNumber": "123456789",
                "accountNumber": "123456890123"
            },
            "processor": "manual"
        }
    },
    "paymentTerm": "upon_receipt",
    "contractItems": [
        {
            "id": "02d0e120-2c14-40e1-8a5e-c4e2e5fe9093",
            "createdAt": "2023-02-17T14:54:58.982811Z",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-17T14:54:58.982811Z",
            "quantity": 75.0000,
            "product": {
                "id": "b201149e-6417-491a-a873-2d763b93715c",
                "createdAt": "2023-02-17T14:46:30.592739Z",
                "createdBy": "[email protected]",
                "updatedAt": "2023-03-16T14:13:16.655444Z",
                "updatedBy": "system",
                "hidden": false,
                "name": "Graduated Platform Fee",
                "internalName": "",
                "description": "",
                "enhanced": true,
                "recurrence": "recurring",
                "pricing": "graduated",
                "consumption": "multiple",
                "status": "active",
                "unit": {
                    "id": "b0751c5d-ef5b-4143-b9f5-109e2eb4a23e",
                    "createdAt": "2022-11-26T18:30:06.803405Z",
                    "createdBy": "[email protected]",
                    "updatedAt": "2022-11-26T18:30:06.803408Z",
                    "name": "Seat",
                    "plural": "Seats"
                },
                "unitId": "b0751c5d-ef5b-4143-b9f5-109e2eb4a23e",
                "levels": [
                    {
                        "start": 0,
                        "price": {
                            "amount": 100000,
                            "scale": 2,
                            "formattedAmount": "$1,000.00",
                            "currency": "USD"
                        },
                        "quarterPrice": {
                            "amount": 300000,
                            "scale": 2,
                            "formattedAmount": "$3,000.00",
                            "currency": "USD"
                        },
                        "halfyearPrice": {
                            "amount": 600000,
                            "scale": 2,
                            "formattedAmount": "$6,000.00",
                            "currency": "USD"
                        },
                        "yearPrice": {
                            "amount": 1200000,
                            "scale": 2,
                            "formattedAmount": "$12,000.00",
                            "currency": "USD"
                        }
                    },
                    {
                        "start": 11,
                        "price": {
                            "amount": 95000,
                            "scale": 2,
                            "formattedAmount": "$950.00",
                            "currency": "USD"
                        },
                        "quarterPrice": {
                            "amount": 285000,
                            "scale": 2,
                            "formattedAmount": "$2,850.00",
                            "currency": "USD"
                        },
                        "halfyearPrice": {
                            "amount": 570000,
                            "scale": 2,
                            "formattedAmount": "$5,700.00",
                            "currency": "USD"
                        },
                        "yearPrice": {
                            "amount": 1140000,
                            "scale": 2,
                            "formattedAmount": "$11,400.00",
                            "currency": "USD"
                        }
                    },
                    {
                        "start": 26,
                        "price": {
                            "amount": 90000,
                            "scale": 2,
                            "formattedAmount": "$900.00",
                            "currency": "USD"
                        },
                        "quarterPrice": {
                            "amount": 270000,
                            "scale": 2,
                            "formattedAmount": "$2,700.00",
                            "currency": "USD"
                        },
                        "halfyearPrice": {
                            "amount": 540000,
                            "scale": 2,
                            "formattedAmount": "$5,400.00",
                            "currency": "USD"
                        },
                        "yearPrice": {
                            "amount": 1080000,
                            "scale": 2,
                            "formattedAmount": "$10,800.00",
                            "currency": "USD"
                        }
                    },
                    {
                        "start": 51,
                        "price": {
                            "amount": 85000,
                            "scale": 2,
                            "formattedAmount": "$850.00",
                            "currency": "USD"
                        },
                        "quarterPrice": {
                            "amount": 255000,
                            "scale": 2,
                            "formattedAmount": "$2,550.00",
                            "currency": "USD"
                        },
                        "halfyearPrice": {
                            "amount": 510000,
                            "scale": 2,
                            "formattedAmount": "$5,100.00",
                            "currency": "USD"
                        },
                        "yearPrice": {
                            "amount": 1020000,
                            "scale": 2,
                            "formattedAmount": "$10,200.00",
                            "currency": "USD"
                        }
                    },
                    {
                        "start": 101,
                        "price": {
                            "amount": 80000,
                            "scale": 2,
                            "formattedAmount": "$800.00",
                            "currency": "USD"
                        },
                        "quarterPrice": {
                            "amount": 240000,
                            "scale": 2,
                            "formattedAmount": "$2,400.00",
                            "currency": "USD"
                        },
                        "halfyearPrice": {
                            "amount": 480000,
                            "scale": 2,
                            "formattedAmount": "$4,800.00",
                            "currency": "USD"
                        },
                        "yearPrice": {
                            "amount": 960000,
                            "scale": 2,
                            "formattedAmount": "$9,600.00",
                            "currency": "USD"
                        }
                    }
                ],
                "discountable": true,
                "options": {
                    "allowCustomization": true
                },
                "uri": "/api/latest/settings/products/b201149e-6417-491a-a873-2d763b93715c"
            },
            "productId": "b201149e-6417-491a-a873-2d763b93715c",
            "contractId": "2274ed9c-dc18-453c-b953-4d981ce00e38"
        }
    ],
    "billingSchedules": [
        {
            "id": "20a7fa6c-1914-465f-9a6e-095459239fef",
            "createdAt": "2023-02-17T14:48:30.647127Z",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-17T14:48:30.647129Z",
            "scheduleDate": "2022-12-05",
            "amountDue": 34500000,
            "transfer": {
                "id": "96a9c59b-f189-4341-9212-01ed18b8ac25",
                "createdAt": "2023-02-17T14:51:12.438641Z",
                "createdBy": "[email protected]",
                "updatedAt": "2023-02-17T14:51:12.438642Z",
                "amount": 34500000,
                "status": "pending",
                "type": "DEBIT",
                "processor": "manual",
                "paymentType": "ach",
                "category": "PAYMENT",
                "paymentMethod": {
                    "id": "a8e368e5-5d55-479e-9cc8-821d91d90058",
                    "createdAt": "2022-11-23T18:53:06.547738Z",
                    "createdBy": "[email protected]",
                    "updatedAt": "2023-01-20T14:16:06.192054Z",
                    "updatedBy": "[email protected]",
                    "name": "ACH",
                    "description": "Pay via bank",
                    "enabled": true,
                    "configured": true,
                    "managed": false,
                    "billingPeriods": [
                        "quarter",
                        "year",
                        "month"
                    ],
                    "paymentType": "ach",
                    "configuration": {
                        "accountName": "JCBank",
                        "bankName": "BankofJC",
                        "routingNumber": "123456789",
                        "accountNumber": "123456890123"
                    },
                    "processor": "manual"
                },
                "referenceId": "20a7fa6c-1914-465f-9a6e-095459239fef",
                "referenceType": "billingschedule"
            },
            "dueDate": "2022-12-05",
            "issueDate": "2022-12-05",
            "billingItems": [
                {
                    "id": "db798b94-65de-467e-91a9-7b744d5b929b",
                    "createdAt": "2023-03-16T14:58:48.078099Z",
                    "createdBy": "system",
                    "updatedAt": "2023-03-16T14:58:48.0781Z",
                    "billingType": "product",
                    "amountDue": 34500000,
                    "quantity": 30.0000,
                    "product": {
                        "referenceType": "product",
                        "id": "b201149e-6417-491a-a873-2d763b93715c",
                        "uri": "/api/latest/settings/products/b201149e-6417-491a-a873-2d763b93715c"
                    }
                }
            ],
            "parentReferenceKey": {
                "referenceType": "contract",
                "referenceId": "2274ed9c-dc18-453c-b953-4d981ce00e38"
            },
            "referenceType": "billingschedule"
        },
        {
            "id": "787e08b1-1188-42e4-86fe-b0b049f41385",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-17T14:49:22.699773Z",
            "updatedBy": "[email protected]",
            "scheduleDate": "2023-02-05",
            "amountDue": 35000000,
            "transfer": {
                "id": "de37f08c-431e-4e0b-9e61-ed6f385080bd",
                "createdAt": "2023-02-17T14:51:12.441033Z",
                "createdBy": "[email protected]",
                "updatedAt": "2023-03-16T15:09:53.164159Z",
                "updatedBy": "[email protected]",
                "amount": 33484932,
                "status": "pending",
                "type": "DEBIT",
                "processor": "manual",
                "paymentType": "ach",
                "category": "PAYMENT",
                "paymentMethod": {
                    "id": "a8e368e5-5d55-479e-9cc8-821d91d90058",
                    "createdAt": "2022-11-23T18:53:06.547738Z",
                    "createdBy": "[email protected]",
                    "updatedAt": "2023-01-20T14:16:06.192054Z",
                    "updatedBy": "[email protected]",
                    "name": "ACH",
                    "description": "Pay via bank",
                    "enabled": true,
                    "configured": true,
                    "managed": false,
                    "billingPeriods": [
                        "quarter",
                        "year",
                        "month"
                    ],
                    "paymentType": "ach",
                    "configuration": {
                        "accountName": "JCBank",
                        "bankName": "BankofJC",
                        "routingNumber": "123456789",
                        "accountNumber": "123456890123"
                    },
                    "processor": "manual"
                },
                "referenceId": "787e08b1-1188-42e4-86fe-b0b049f41385",
                "referenceType": "billingschedule"
            },
            "dueDate": "2023-02-05",
            "issueDate": "2023-02-05",
            "billingItems": [
                {
                    "id": "577470d0-ceeb-4eb0-8633-fa7bdef834d0",
                    "createdAt": "2023-03-16T14:58:48.080054Z",
                    "createdBy": "system",
                    "updatedAt": "2023-03-16T14:58:48.080055Z",
                    "billingType": "product",
                    "amountDue": -27505479,
                    "quantity": 30.0000,
                    "proration": -79,
                    "product": {
                        "referenceType": "product",
                        "id": "b201149e-6417-491a-a873-2d763b93715c",
                        "uri": "/api/latest/settings/products/b201149e-6417-491a-a873-2d763b93715c"
                    }
                },
                {
                    "id": "2d27b4bd-4b0d-4eb6-9c3d-0d8981d701a9",
                    "createdAt": "2023-03-16T14:58:48.080531Z",
                    "createdBy": "system",
                    "updatedAt": "2023-03-16T14:58:48.080532Z",
                    "billingType": "product",
                    "amountDue": 60990411,
                    "quantity": 70.0000,
                    "proration": 79,
                    "product": {
                        "referenceType": "product",
                        "id": "b201149e-6417-491a-a873-2d763b93715c",
                        "uri": "/api/latest/settings/products/b201149e-6417-491a-a873-2d763b93715c"
                    }
                }
            ],
            "parentReferenceKey": {
                "referenceType": "contract",
                "referenceId": "2274ed9c-dc18-453c-b953-4d981ce00e38"
            },
            "referenceType": "billingschedule"
        },
        {
            "id": "44b12776-2878-4823-ac64-2dc2b90709d8",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-17T14:54:58.989191Z",
            "updatedBy": "[email protected]",
            "scheduleDate": "2023-02-17",
            "amountDue": 4067857,
            "transfer": {
                "id": "cc95507a-c026-47fa-aa41-4f0ed94d93f6",
                "createdAt": "2023-02-17T14:56:13.726351Z",
                "createdBy": "[email protected]",
                "updatedAt": "2023-03-16T15:09:53.164714Z",
                "updatedBy": "[email protected]",
                "amount": 4066027,
                "status": "pending",
                "type": "DEBIT",
                "processor": "manual",
                "paymentType": "ach",
                "category": "PAYMENT",
                "paymentMethod": {
                    "id": "a8e368e5-5d55-479e-9cc8-821d91d90058",
                    "createdAt": "2022-11-23T18:53:06.547738Z",
                    "createdBy": "[email protected]",
                    "updatedAt": "2023-01-20T14:16:06.192054Z",
                    "updatedBy": "[email protected]",
                    "name": "ACH",
                    "description": "Pay via bank",
                    "enabled": true,
                    "configured": true,
                    "managed": false,
                    "billingPeriods": [
                        "quarter",
                        "year",
                        "month"
                    ],
                    "paymentType": "ach",
                    "configuration": {
                        "accountName": "JCBank",
                        "bankName": "BankofJC",
                        "routingNumber": "123456789",
                        "accountNumber": "123456890123"
                    },
                    "processor": "manual"
                },
                "referenceId": "44b12776-2878-4823-ac64-2dc2b90709d8",
                "referenceType": "billingschedule"
            },
            "dueDate": "2023-02-17",
            "issueDate": "2023-02-17",
            "statementSentAt": "2023-02-17",
            "billingItems": [
                {
                    "id": "835f9f61-2507-4db9-b703-656b10de08cd",
                    "createdAt": "2023-03-16T14:58:48.082401Z",
                    "createdBy": "system",
                    "updatedAt": "2023-03-16T14:58:48.082402Z",
                    "billingType": "product",
                    "amountDue": -60990411,
                    "quantity": 70.0000,
                    "proration": -79,
                    "product": {
                        "referenceType": "product",
                        "id": "b201149e-6417-491a-a873-2d763b93715c",
                        "uri": "/api/latest/settings/products/b201149e-6417-491a-a873-2d763b93715c"
                    }
                },
                {
                    "id": "fa7262b7-10bc-452c-b6bf-516580886b20",
                    "createdAt": "2023-03-16T14:58:48.08434Z",
                    "createdBy": "system",
                    "updatedAt": "2023-03-16T14:58:48.084341Z",
                    "billingType": "product",
                    "amountDue": 65056438,
                    "quantity": 75.0000,
                    "proration": 79,
                    "product": {
                        "referenceType": "product",
                        "id": "b201149e-6417-491a-a873-2d763b93715c",
                        "uri": "/api/latest/settings/products/b201149e-6417-491a-a873-2d763b93715c"
                    }
                }
            ],
            "parentReferenceKey": {
                "referenceType": "contract",
                "referenceId": "2274ed9c-dc18-453c-b953-4d981ce00e38"
            },
            "referenceType": "billingschedule"
        }
    ],
    "currencyCode": "USD",
    "timeunitType": "month",
    "shortId": "236",
    "nextPaymentDue": {
        "id": "20a7fa6c-1914-465f-9a6e-095459239fef",
        "createdAt": "2023-02-17T14:48:30.647127Z",
        "createdBy": "[email protected]",
        "updatedAt": "2023-02-17T14:48:30.647129Z",
        "scheduleDate": "2022-12-05",
        "amountDue": 34500000,
        "transfer": {
            "id": "96a9c59b-f189-4341-9212-01ed18b8ac25",
            "createdAt": "2023-02-17T14:51:12.438641Z",
            "createdBy": "[email protected]",
            "updatedAt": "2023-02-17T14:51:12.438642Z",
            "amount": 34500000,
            "status": "pending",
            "type": "DEBIT",
            "processor": "manual",
            "paymentType": "ach",
            "category": "PAYMENT",
            "paymentMethod": {
                "id": "a8e368e5-5d55-479e-9cc8-821d91d90058",
                "createdAt": "2022-11-23T18:53:06.547738Z",
                "createdBy": "[email protected]",
                "updatedAt": "2023-01-20T14:16:06.192054Z",
                "updatedBy": "[email protected]",
                "name": "ACH",
                "description": "Pay via bank",
                "enabled": true,
                "configured": true,
                "managed": false,
                "billingPeriods": [
                    "quarter",
                    "year",
                    "month"
                ],
                "paymentType": "ach",
                "configuration": {
                    "accountName": "JCBank",
                    "bankName": "BankofJC",
                    "routingNumber": "123456789",
                    "accountNumber": "123456890123"
                },
                "processor": "manual"
            },
            "referenceId": "20a7fa6c-1914-465f-9a6e-095459239fef",
            "referenceType": "billingschedule"
        },
        "dueDate": "2022-12-05",
        "issueDate": "2022-12-05",
        "billingItems": [
            {
                "id": "db798b94-65de-467e-91a9-7b744d5b929b",
                "createdAt": "2023-03-16T14:58:48.078099Z",
                "createdBy": "system",
                "updatedAt": "2023-03-16T14:58:48.0781Z",
                "billingType": "product",
                "amountDue": 34500000,
                "quantity": 30.0000,
                "product": {
                    "referenceType": "product",
                    "id": "b201149e-6417-491a-a873-2d763b93715c",
                    "uri": "/api/latest/settings/products/b201149e-6417-491a-a873-2d763b93715c"
                }
            }
        ],
        "parentReferenceKey": {
            "referenceType": "contract",
            "referenceId": "2274ed9c-dc18-453c-b953-4d981ce00e38"
        },
        "referenceType": "billingschedule"
    }
}