DigitalOcean Marketplace Vendor SaaS Add-Ons API Documentation
- Getting Started
- Definitions
- Creating Your Listing
- Authentication
- Retries
- Timeouts
- Provision
- Asynchronous Provisioning
- Deprovision
- Plan Change (Upgrade/Downgrade)
- Notifications
- Resource Suspension
- Resource Reactivation
- Resource Deprovisioning Failure
- Resource Updated
- Single Sign-On
- Authorization Code Exchange
- Access Token Refresh
- Resource Config Update
- Metadata
- Add custom fields to your Add-On
- Receive metadata in resource creation payload
- Abusive Users
- Tips for Testing your Add-On
- Testing provisioning via the Preview button
- Testing provisioning via the Plan Information tab
Getting Started
DigitalOcean Marketplace engineers will support your team as they onboard your Software-as-a Service Add-On to the DigitalOcean Marketplace. To get started, you need a DigitalOcean account to create a Team to later associate with your Add-On, and then you’ll need to register as a Vendor.
Once approved, you’ll be able to access the Marketplace Vendor Portal, where you’ll start by creating your Add-On listing. Your listing is home to your SaaS Add-On’s configuration information, as well as public-facing information for prospective users to use to evaluate your services.
Definitions
Before getting started, familiarize yourself with the terminology used for DigitalOcean Marketplace Vendors. You’ll see these throughout the interface and documentation.
Add-On = Software-as-a-service made available through the DigitalOcean Marketplace.
App = The vendor’s application that the DigitalOcean API talks to.
Resource = An instance of an Add-On the user provisions through the DigitalOcean Marketplace. A Marketplace resource typically maps one-to-one with an account on your SaaS service.
Vendor = The person or company whose Add-On is available on the DigitalOcean Marketplace.
Creating Your Listing
When creating your Add-On listing, you’ll want to have both SEO and naming best practices in mind. For instance, SaaS Company, Inc. would be the name of the Vendor, and the Add-On’s app_slug (app API identifier) would be saas-name. Most vendors have multiple Add-On listings, including one for each of their production and staging environments. To continue our example, the Add-On for the staging environment may have an app_slug of saas-name-staging. For each Add-On, you'll list your payment plans and the features that come with each plan, as well as provide information about support and additional resources.
When you create an Add-On listing, you'll be given a set of credentials including a password, salt, and client_secret. Store these securely on your end. You will use the password to authenticate API requests coming from DigitalOcean to your app, the salt to authenticate SSO requests, and the client_secret to exchange an authorization_code for an access_token and refresh_token, to be used when making requests back to DigitalOcean's SaaS API.
Authentication
When DigitalOcean makes API requests to your app's endpoints, we will utilize basic auth. The auth header will contain a base64 encoded string consisting of your app's slug and the pre-shared password in the format: slug:password. For example, an app whose slug is acme and password is 1234 will receive requests with the following authorization header: Authorization: Basic YWNtZToxMjM0.
Retries
A request may be sent multiple times. Therefore, if a request includes a uuid, the response needs to be idempotent.
Timeouts
Your app should respond within no more than 30 seconds. If you need more than 30 seconds to handle the provision request, please use the asynchronous provisioning option.
Provision
When a DigitalOcean user installs an Add-On, DigitalOcean will send a resource provisioning request to your app’s registered endpoint:
Your app will then respond with the following:
Your app can use the config section of the response to send back information customers will need to use your Add-On. This is typically API keys, login details, or other private credentials, but could be used to provide other types of information as well.
The customer will be able to access this through the Add-On UI in the Control Panel. When displayed, the “configuration variable prefix” will be appended to the variable name you supply.
Config variables can also be updated as described below.
In the event that the resource cannot be created, respond with the following:
If the provision request was successful, but your app is using the asynchronous provisioning option, respond with the following:
Asynchronous Provisioning
If your app needs more than 30 seconds to handle the resource provision request, you may use the asynchronous provisioning option.
The first step is to have your app respond to the resource provision request with the following:
Then, follow the instructions for the Authorization Code Exchange. You will need an access_token to asynchronously provision this resource.
Finally, once your app has the access_token for the resource and has completed provisioning, it will make a POST request to the callback_url value provided in the original provision request. Make sure to include the access_token in the Authorization header:
Deprovision
When a DigitalOcean user requests that a resource be destroyed, DigitalOcean will send the following request to your app’s registered endpoint:
Your app will then respond with the following:
In the event that the resource cannot be found, respond with the following:
In the event that the resource cannot be destroyed, respond with the following:
Plan Change (Upgrade/Downgrade)
DigitalOcean users can request to change their plan at any time through the DigitalOcean control panel. Plans cannot be changed by Vendors or within the Vendor application. When a DigitalOcean user requests a plan change, DigitalOcean will send the following request to your app’s registered endpoint:
Your app will then respond with the following:
If you do not wish to return a message, respond with the following instead:
In the event that the plan cannot be changed, respond with the following:
In the event that the resource cannot be found, respond with the following:
Notifications
Occasionally, DigitalOcean will send important notifications regarding your app or its users. These are often sent by email and by POSTing to a notifications endpoint on your app. The types of notifications we send are summarized here, but could be extended in the future.
Resource Suspension
resources.suspended
A resource may be suspended if a user is late paying their invoice. DigitalOcean will notify your app when one or more resources have been suspended with a request of type resources.suspended.
Resource Reactivation
resources.reactivated
A resource may be reactivated if a user pays their late invoice. DigitalOcean will notify your app when one or more resources have been reactivated with a request of type resources.reactivated.
Resource Deprovisioning Failure
resources.deprovisioning.failed
If a user destroys a resource, your app will be sent a deprovisioning request as described above. If your app does not correctly handle the request, we will notify you with a notification of type resources.deprovisioning.failed.
Resource Updated
resources.updated
A user has the option to rename a resource. Upon renaming one of their Add-On resources, DigitalOcean will send you a resources.updated request, which includes the full state of the resource.
Single Sign-On
DigitalOcean users of your SaaS Add-On should be able to log into your app’s dashboard. When a user wants to SSO from DigitalOcean to your app’s dashboard, we will send the following request to your app’s registered endpoint:
Parameters:
resource_uuid: The UUID provided by DigitalOcean during provisioning.
auth_token: Hex encoded, HMAC SHA256 encrypted hash of "timestamp:resource_uuid:user_id:user_email" with the salt as the HMAC key; this is used to authenticate the request
timestamp: Unix timestamp of when the SSO request was made
user_email: An obfuscated email that is linked to the user logging in to your app.
user_id: An obfuscated string representing the user’s uuid.
Your app will need to validate the request from DigitalOcean by verifying the auth_token. This is done by creating your own HMAC hash from timestamp:resource_uuid:user_id:user_email, using the salt as the secret key and SHA256 as the message digest algorithm, and then Hex encoding it. The resource_uuid, user_id, user_email, and timestamp will be in the request. The salt was provided to you when you created your Add-On listing.
Note: It is up to you to “expire” tokens using the timestamp provided. A best practice would be to reject any tokens with a timestamp older than a minute or two.
Note: You may see a parameter in the request called token in addition to auth_token. This is a deprecated value included solely to support legacy integrations during a migration period and should not be used for your SSO integration. Use auth_token to validate your request.
Here are code examples for validating the token.
If the auth_token is valid, your app will create a session cookie for the user, and then respond with the following, allowing the user to proceed to your dashboard in a logged-in state:
In the event that the auth_token cannot be verified, respond with the following:
Authorization Code Exchange
When a resource is provisioned, an authorization_code (which expires after 5 minutes) is provided that will need to be exchanged for an access_token and refresh_token. The access_token has a finite lifespan and gives you the ability to modify the variables for a specific resource. The refresh_token is used to retrieve a new access_token once the old one has expired.
Example authorization_code -
To request a access_token and refresh_token:
Access Token Refresh
If your apps access_token has expired, you will need to use the refresh_token returned above to request a new access_token, by making the following request:
DigitalOcean will respond with an updated access_token and a new refresh_token:
Resource Config Update
Your app can create or update config variables that a customer will need to use your Add-On. This is typically API keys, log in details, or other private credentials, but could be used to provide other types of information as well.
The customer will be able to access this through their Add-On UI. When displayed, the “configuration variable prefix” will be appended to the variable name you supply.
Using an access_token, your app can add to, or update the config variables for a given resource.
To update the config variables for a given resource send the access token in the Authorization header.
The body of your app's request should include the variables you wish to update alongside the value for each.
Note: variables can be updated, but cannot be destroyed. It is recommended that your variables follow the ALL_CAPS naming convention.
Metadata
When creating an Add-On listing, you have the option to add custom form fields that will be incorporated into the sign-up process. The values provided by a user will be stored with the resource as metadata. Metadata are sent to you during resource creation as part of the provisioning request.
Note: All custom fields you add are required and must be completed by the user.
Add custom fields to your Add-On
To add custom fields to your Add-On, you will need to specify the following for each field:
name: The name is unique among all custom fields for a given Add-On. It is also going to be the slug sent back to you as part of the resource provision payload.
display_name: Human readable name of configurable variable. DigitalOcean will use the name in the Add-On sign-up form.
description: A description of the configurable variable
type: The data type of the expected input value. Currently we support boolean and text string inputs.
options: Options are a list of possible responses for a string custom field. If you provide options, the string input will be changed to a select field with corresponding options.
Example -
Receive metadata in resource creation payload
User-supplied metadata will be included in the resource provision payload. The “metadata” section will include the key-value representation of the metadata, where the key will be the name of the metadata and value will be the user input.
Example payload -
Note: DigitalOcean Terms of Service prohibit you from collecting email addresses through the custom fields/metadata feature.
Abusive Users
If you determine that a user from DigitalOcean is being abusive on your platform, please submit a ticket in the Marketplace Help Center with the following information:
- The resource_uuid
- If you have these, include: the DigitalOcean user_id that is associated with the abusive account and the creator_id.
- A thorough description of the abuse.
Tips for Testing your Add-On
Once you have built your integration, test it and make sure everything works as expected. As a reminder, ensure any person testing your Add-On is a member of the Team associated with the Add-On in Vendor Portal. For more information, review our Team documentation. From the Vendor Portal UI, there are two ways to test resource provisioning:
Testing provisioning via the Preview button
You can find a Preview button at the bottom of your Add-On’s Create or Edit Listing page. When you select the Preview button, you’ll be shown your Add-On’s listing page in preview mode. From here, you can test provisioning by selecting the Add your-addon button, and verifying the account was provisioned on your service.
Testing provisioning via the Plan Information tab
On the Plan Information tab within your Add-On’s listing, find the Plans section and select the more menu button to the right of the plan you want to test. Selecting Test Plan will provision a resource for that specific plan.
Note: Provisioning paid plans in this way will skip our billing logic, so you should never be charged.
Once you have successfully provisioned a resource (and matching account) on your service, you should test:
- Plan Changes: Verify that your SaaS changes the plan and account limits for the customer
- Single Sign-On: Verify that you can SSO to your SaaS
- Resource Destruction: Verify that destroying the resource via DigitalOcean removes the corresponding account on your SaaS.
- Notifications: You can test notifications by provisioning a resource, and then changing its name using the edit resources settings form. This will elicit a resources.updated webhook to your service.