Codebase API Documentation

Public Keys

When working with Git or Mercurial repositories, you need to connect to the Codebase system using SSH. To authenticate, your SSH request you need to add your SSH public key to your user account or a project.

API URLs

You an use any of the API urls below to retrieve information about repositories within individual projects. You need to pass the project's permalink into the URL for all requests.

Data Method URL
All public keys for a user GET /users/username/public_keys
All public keys for a user (as text) GET /users/username/public_keys.txt
All deployment keys for a project GET /project/public_keys
All deployment keys for a repository **new** GET /project/repository/public_keys
All deployment keys for a project (as text) GET /project/public_keys.txt
Adding a new user key POST /users/username/public_keys
Adding a new project deployment key POST /project/public_keys
Adding a new repository deployment key **new** POST /project/repository/public_keys

Object Properties

The XML output below shows the properties which are returned by default when accessing project details.

GET /project/public_keys

<public-key-join>
  <description>My Example Key</description>
  <key>ssh-rsa AAAAB3NzaC1yAAAQEAsAOV[...]Vs2TrWJkRNq5eJVw==</key>
</public-key-join>
  • description is the description of the key entered when the key was added
  • key the full SSH public key (without any comments, comments are stripped and not saved when the key is added)

Adding a new key

When creating a new key, you should simply send the object definition (as shown above) to the URLs listed in the API URLs table.

To generate a new SSH keypair on your local machine, you can issue ssh-keygen on any machine running SSH. The contents of the id_rsa.pub file should be copied into the key field when adding to Codebase.

Note: When adding a key, your root level element should be <public-key>, not <public-key-join>. For example:

<public-key>
  <description>My Example Key</description>
  <key>ssh-rsa AAAAB3NzaC1yAAAQEAsAOV[...]Vs2TrWJkRNq5eJVw==</key>
</public-key>