Intro

These endpoints enables you to maintain your account programatically.

Authentication

All requests to the API must include a base64 encoded version API token you can copy from your account.

If you e.g. want to update a collection that has _id 5bf935bc3ab42fc4f4280d04, and your API token is p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f, then your request should look like this:

PATCH /api/v1/collections/5bf935bc3ab42fc4f4280d04
Host: https://goaddon.com
Content-Type: application/json
Accept: application/json
Authorization: Basic cC1lMWY5MmM3Ny01YmIwLTRmYjgtOWJkOC05YjYxZDAxNGFiNWY=
{
  "foo": "bar"
}

Unauthorized requests will responded with 401 Unauthorized.

Resources
collections

As an addon your access to projects databases is limited. You only get access to the collections you have registered. As a project you have full access.

A collection has indexes, and when a project registers one we will create it in their MongoDB. Or if an addon registers one, we will create it for all the projects that are subscribed to the addon.

Name Type Description

_id

BSON::ObjectId

klass

String

The class of the collection, pluralized. E.g. companies, orders, products, etc.

_fields

Array

As an addon the attributes you register will be listed in a database overview that projects can review. If you as a project register the attributes you intend to use we will present you with the collections that overlaps with the addons you subscribe to.

[
  {
    "name": "foo",
    "type": "String",
    "description": "Contains the `foo` variable."
  }
]

indexes

Array

You may define as many indexes as you need.

An index consists of one or more keys, each either sorted ascending or descending.

Additionally in options you can define if the set of keys should be validated for uniqueness.

[
  {
    "key": {
      "foo": 1
    }
  },
  {
    "key": {
      "company_id": 1,
      "foo": 1
    },
    "options": {
      "unique": true,
      "sparse": true,
      "name": "company_foo"
    }
  }
]

Description

Get all collections.

Request

Optionally you can paginate results by including any of the following params in your request string:

Name Description Default value Max. value
per_page The max. number of documents you want returned 100 500
page The page number, starts at 0 0 -
HTTParty.get(
  "https://goaddon.com/api/v1/collections?per_page=100&page=0",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
documents

An array with the requested documents.

Name Description
error

A text description of the error.

No response body.

Description

Get specific collection.

Request

No params required.

HTTParty.get(
  "https://goaddon.com/api/v1/collections/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
document

The requested document.

Name Description
error

A text description of the error.

No response body.

Description

Create a collection.

DANGER! Changing indexes will immediately trigger reindexing of all affected databases.

Request

Include the following keys:

{
  "klass": "companies",
  "description": "A `company` owns almost all other resources.",
  "_fields": [
    {
      "name": "_id",
      "type": "BSON::ObjectId",
      "description": ""
    },
    {
      "name": "website",
      "type": "String",
      "description": "The company website."
    },
    {
      "name": "email",
      "type": "String",
      "description": "The company email."
    }
  ],
  "indexes": [
    {
      "key": {
        "email": 1
      }
    },
    {
      "key": {
        "website": 1
      },
      "options": {
        "unique": true,
        "sparse": true
      }
    }
  ]
}
HTTParty.post(
  "https://goaddon.com/api/v1/collections",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: body.to_json
)
Response
Name Description
success

A text confirmation that a document was successfully created.

_id

The _id of the created document.

Name Description
error

A text description of the error.

No response body.

Description

Update a collection.

DANGER! Changing indexes will immediately trigger reindexing of all affected databases.

Request

Include any of the following keys in your JSON body:

{
  "klass": "companies",
  "description": "A `company` owns almost all other resources.",
  "_fields": [
    {
      "name": "_id",
      "type": "BSON::ObjectId",
      "description": ""
    },
    {
      "name": "website",
      "type": "String",
      "description": "The company website."
    },
    {
      "name": "email",
      "type": "String",
      "description": "The company email."
    }
  ],
  "indexes": [
    {
      "key": {
        "email": 1
      }
    },
    {
      "key": {
        "website": 1
      },
      "options": {
        "unique": true,
        "sparse": true
      }
    }
  ]
}
HTTParty.patch(
  "https://goaddon.com/api/v1/collections/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: body.to_json
)
Response
Name Description
success

A text confirmation describing if the document was successfully updated.

message

A text confirmation describing if the document was recognized, but that there was no new data to update with.

Name Description
error

A text description of the error.

No response body.

Description

Destroy a collection.

DANGER! Changing indexes will immediately trigger reindexing of all affected databases.

Request

No params required.

HTTParty.delete(
  "https://goaddon.com/api/v1/collections/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
message

A text confirmation that the document was destroyed.

Name Description
error

A text description of the error.

No response body.

Description

Replace all existing collections with the ones you submit.

DANGER! Changing indexes will immediately trigger reindexing of all affected databases.

Request

Include an array of hashes like this:

{
  "collections": [
    {}
  ]
}

Each hash should contain the following keys:

{
  "klass": "companies",
  "description": "A `company` owns almost all other resources.",
  "_fields": [
    {
      "name": "_id",
      "type": "BSON::ObjectId",
      "description": ""
    },
    {
      "name": "website",
      "type": "String",
      "description": "The company website."
    },
    {
      "name": "email",
      "type": "String",
      "description": "The company email."
    }
  ],
  "indexes": [
    {
      "key": {
        "email": 1
      }
    },
    {
      "key": {
        "website": 1
      },
      "options": {
        "unique": true,
        "sparse": true
      }
    }
  ]
}
HTTParty.post(
  "https://goaddon.com/api/v1/collections/reset",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: body.to_json
)
Response
Name Description
created

An integer of the number of documents that was created.

updated

An integer of the number of documents that was updated.

destroyed

An integer of the number of documents that was destroyed.

Name Description
error

A text description of the error.

No response body.

db_users

In order to access your database you need to create database users.

Name Type Description

_id

BSON::ObjectId

username

String

The username of the database user. E.g. myuser.

password

String

The password of the database user. E.g. 123456789.

roles

Array

The roles of the database user. E.g. ['readWrite'].

Description

Get all database users.

Request

Optionally you can paginate results by including any of the following params in your request string:

Name Description Default value Max. value
per_page The max. number of documents you want returned 100 500
page The page number, starts at 0 0 -
HTTParty.get(
  "https://goaddon.com/api/v1/db_users?per_page=100&page=0",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
documents

An array with the requested documents.

Name Description
error

A text description of the error.

No response body.

Description

Get specific database user.

Request

No params required.

HTTParty.get(
  "https://goaddon.com/api/v1/db_users/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
document

The requested document.

Name Description
error

A text description of the error.

No response body.

Description

Create a database user.

Request

Include the following keys:

{
  "username": "my_user",
  "password": "123456789",
  "roles": [
    "readWrite"
  ]
}
HTTParty.post(
  "https://goaddon.com/api/v1/db_users",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: body.to_json
)
Response
Name Description
success

A text confirmation that a document was successfully created.

_id

The _id of the created document.

Name Description
error

A text description of the error.

No response body.

Description

Update a database user.

Request

Include any of the following keys in your JSON body:

{
  "username": "my_user",
  "password": "123456789",
  "roles": [
    "readWrite"
  ]
}
HTTParty.patch(
  "https://goaddon.com/api/v1/db_users/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: body.to_json
)
Response
Name Description
success

A text confirmation describing if the document was successfully updated.

message

A text confirmation describing if the document was recognized, but that there was no new data to update with.

Name Description
error

A text description of the error.

No response body.

Description

Destroy a database user.

Request

No params required.

HTTParty.delete(
  "https://goaddon.com/api/v1/db_users/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
message

A text confirmation that the document was destroyed.

Name Description
error

A text description of the error.

No response body.

projects

You can manage some of your project settings through this API.

Name Type Description

_id

BSON::ObjectId

name

String

The name of your project or company, e.g. My Company.

company

String

The company who legally has ownership of this account.

address_1

String

The address of your company.

address_2

String

An optional second address line of your company.

zip_code

String

The Zip code of the city where your company is legally located.

city

String

The city where your company is legally located.

province

String

The province, state or region where your company is legally located.

country

String

The country where your company is legally located.

email

String

The email address where you would like to receive information about billing.

vat_number

String

The VAT ID that should be applied to invoices.

db_plan

Hash

The chosen database configuration for your project, e.g. {'hcloud_fsn1__cx11': 3}

db_hosts

The host URL's of your database. This is neccesary knowledge when connecting to your Goaddon database, e.g. ['5bf935bc3ab42fc4f4280d05-0.mongodb.goaddon.com', '5bf935bc3ab42fc4f4280d05-1.mongodb.goaddon.com'].

db_name

String

The name of your Goaddon database.

encryption_key

String

The key that is used, together with the encryption_iv, to encrypt and decrypt data from the database, e.g. 49b97a6f8362315d27921d6c4db71ef5e4798c24ea0d62b367f3ee5d1bd96f8b.

encryption_iv

String

The iv that is used, together with the encryption_key, to encrypt and decrypt data from the database, e.g. 51cd115466d508d77da8996f45f374e4.

zone

String

The zone in which your project was created. This determines in which datacenters you can create database nodes, e.g. eu or us.

Description

Get projects.

Request

Optionally you can paginate results by including any of the following params in your request string:

Name Description Default value Max. value
per_page The max. number of documents you want returned 100 500
page The page number, starts at 0 0 -
HTTParty.get(
  "https://goaddon.com/api/v1/projects?per_page=100&page=0",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
documents

An array with the requested documents.

Name Description
error

A text description of the error.

No response body.

Description

Get specific project.

Request

No params required.

HTTParty.get(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
document

The requested document.

Name Description
error

A text description of the error.

No response body.

Description

Update your project.

Request

Include any of the following keys in your JSON body:

{
  "name": "My project",
}
HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: body.to_json
)
Response
Name Description
success

A text confirmation describing if the document was successfully updated.

message

A text confirmation describing if the document was recognized, but that there was no new data to update with.

Name Description
error

A text description of the error.

No response body.

Description

Invite a user to access the project.

Request

Include an email of the user you would like to invite, either as a parameter or as a JSON request body:

{
  "email": "example@example.com"
}
# For example purposes the email is included both as a parameter and inside the request body. Choose the option you prefer.
HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/grant_access?email=example@example.com",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: {email: "example@example.com"}.to_json
)
Response
Name Description
success

A text confirming that the user was granted access.

user_id

The _id to the user that was granted access.

Name Description
error

A text description of the error.

No response body.

Description

Revoke a users access to the project.

Request

Include the user_id of the user that should have his access revoked, either as a parameter or as a JSON request body:

{
  "user_id": "5c10f5133ab42f16f609497c"
}
# For example purposes the user_id is included both as a parameter and inside the request body. Choose the option you prefer.
HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/revoke_access?user_id=5c10f5133ab42f16f609497c",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: {user_id: "5c10f5133ab42f16f609497c"}.to_json
)
Response
Name Description
message

A text confirming that the users access was revoked.

Name Description
error

A text description of the error.

No response body.

Description

Unlock a users access to the project.

Request

Include the user_id of the user that should have his access unlocked, either as a parameter or as a JSON request body:

{
  "user_id": "5c10f5133ab42f16f609497c"
}
# For example purposes the user_id is included both as a parameter and inside the request body. Choose the option you prefer.
HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/unlock_access?user_id=5c10f5133ab42f16f609497c",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: {user_id: "5c10f5133ab42f16f609497c"}.to_json
)
Response
Name Description
success

A text confirming that the users access was unlocked.

Name Description
error

A text description of the error.

No response body.

Description

Configure your database, by changing the number of nodes should participate in your MongoDB Replica Set.

Caution!

Before you start using this API endpoint, be sure to have an intimite understanding about how to safely manage nodes on a Replica Set from Goaddon. One wrong request can cause permanent loss of data.

Request

Include the identifier of the datacenter where you want to change the number of nodes. Also include how many nodes should be in this datacenter.

Submit either as parameters or as a JSON request body:

{
  "identifier": "hcloud_fsn1__cx11",
  "nodes": 3
}

In this example, the number of CX11 nodes in Hetzners Falkenstein datacenter will be adjusted to 3. If other types of nodes exist in your plan they will not be changed unless you submit a separate request for those.

If you want to switch from a dedicated database plan to the Sandbox plan you should submit this:

{
  "identifier": "hcloud_fsn1__sandbox"
}

This will destroy your dedicated database plan along with all data in your dedicated database.

When you submit requests that result in permanent loss of data you are required to provide a verify sentence. The sentence should follow this template:

Delete the database of {{ name }}

If, for example, the name of your account is My Company, you should submit this:

{
  "identifier": "hcloud_fsn1__cx11",
  "nodes": 0,
  "verify": "Delete the database of My Company"
}
# For example purposes the identifier and nodes are included both as a parameters and inside the request body. Choose the option you prefer.
HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/db_configure?identifier=hcloud_fsn1__cx11&nodes=3",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: {identifier: "hcloud_fsn1__cx11", nodes: 3}.to_json
)
Response
Name Description
success

A text confirming that configuration is in progress.

Name Description
error

A text description of the error.

No response body.

Description

Reboot a node in your dedicated MongoDB Replica Set.

Request

Include the node_id of the node that you want to reboot. Or leave it out if you want to reboot all nodes.

Submit either as parameters or as a JSON request body:

{
  "node_id": "5447122"
}
# For example purposes the node_id is included both as a parameter and inside the request body. Choose the option you prefer. If you don't include a node_id all nodes will be rebooted.
HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/db_reboot?node_id=5447122",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: {node_id: "5447122"}.to_json
)
Response
Name Description
message

A text confirming that the node is being rebooted.

Name Description
error

A text description of the error.

No response body.

Description

Poll for the raw output from replSetGetStatus.

The first time you request this endpoint the polling will be initiated. Subsequently you should request it every few seconds in order to actually get the status. A healthy cluster will give a status almost immediately, but if one or more Replica Set members are unhealthy it can take up to 90 seconds. The status will be available up to 5 minutes after your first request.

This endpoint is only accessible if you have a dedicated database plan.

Request

No params required.

HTTParty.get(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/db_status",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
success

A text confirming that the status is included.

repl_set_get_status

The raw output from replSetGetStatus. If polling failed because the database connection timed out this key will contain the response error.

nodes

An array of all nodes. A node will be contain an identifier and an IP address.

requested_at

The time the polling was started.

saved_at

The time the polling was finished and made available.

message

If this is your first request no other keys will be included. Instead a message key will confirm that polling has been initiated or is still in progress.

Name Description
error

A text description of the error.

No response body.

Description

Initiate a failover, where the primary node of your MongoDB Replica Set steps down.

This endpoint is only accessible if you have a dedicated database plan.

Request

No params required.

HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/db_failover",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  }
)
Response
Name Description
success

A text confirming that the db plan switch has been initiated.

Name Description
error

A text description of the error.

No response body.

Description

Reset an access token related to the project. Currently the only token that is eligible for a reset is the api_token, which is used to access this API.

Request

Include the token_name you would like to reset, either as a parameter or as a JSON request body:

{
  "token_name": "webhook_token"
}
# For example purposes the token_name is included both as a parameter and inside the request body. Choose the option you prefer.
HTTParty.patch(
  "https://goaddon.com/api/v1/projects/5bf935bc3ab42fc4f4280d05/reset_token?token_name=webhook_token",
  headers: {
    "Authorization" => "Basic #{Base64.strict_encode64('p-e1f92c77-5bb0-4fb8-9bd8-9b61d014ab5f')}",
    "Content-Type"  => "application/json"
  },
  body: {token_name: "webhook_token"}.to_json
)
Response
Name Description
success

A text confirmation describing that the token was successfully reset.

new_token

The new token, which will take affect immediately.

Name Description
error

A text description of the error.

No response body.