Create project

4 minute read

POST /organizations/{organization_uuid}/projects

Creates a new project.

The following fields/structures are only applicable to Basic projects and will be ignored if the type is set to pro:

  • setup_commands

  • environment_variables

  • test_commands

  • deploy_pipelines

When creating notifications for a project, the following option attributes should be included depending on the notifier:

  • Slack: key

  • Webhook: url

  • Campfire: url, key, room

  • Flowdock: key

When defining a branch filter, a branch match can be a full branch name like main, or a regular expression like ^features.*$. Remember to start a regular expression with ^ and end it with $.

Authentication

  • OAuth2

OAuth2 scopes

  • project.write

Path parameters

Field name Type Required

organization_uuid

string

X

Headers

Field name Type Required

Authorization

string

X

Request body schema

  • Content type: application/json

  • Response schema type: object

Field name Type Required

repository_url

string

X

type

string Allowed values: basic, pro

X

setup_commands

array[string]

test_pipelines

array[object]

  • name

string

  • commands

array[string]

team_ids

array[number]

X

notification_rules

array[object]

  • notifier

string Allowed values: email, slack, campfire, flowdock, webhook

  • target

string Allowed values: all, committer

  • branch

string

  • options

object

key

string

url

string

room

string

  • build_statuses

array[string] Allowed values: started, failed, success, recovered

  • branch_match

string

environment_variables

array[object]

  • name

string

  • value

string

deploy_pipelines

array[object]

  • branch

string

X

  • match_mode

string

X

  • config

array[object]

X

position

number

X

type

string Allowed values: script_deployment, elastic_beanstalk_deployment, s3_deployment, aws_code_deploy_deployment, app_engine_deployment, heroku_deployment

X

aws_access_key_id

string

aws_secret_access_key

string

region

string

application_name

string

environment_name

string

s3_bucket

string

local_path

string

acl

string

deployment_group_name

string

deployment_config_name

string

path

string

url

string

refresh_token

string

name

string

api_key

string

restore_from

string

post_deploy

string

backup

string

force

string

check_url

string

commands

array[string]

build_on_pr_only

boolean

branch_match

string Allowed values: include, exclude

branches

array[string]

Request body example

{
  "repository_url": "https://github.com/codeship/documentation.git",
  "type": "basic",
  "team_ids": [
    99173438,
    64874098,
    74618189,
    92403869
  ],
  "notification_rules": [
    {
      "notifier": "webhook",
      "branch": "development",
      "options": {
        "url": "https://localhost/webhook"
      }
    }
  ],
  "deployment_pipelines": [
    {
      "branch": {
        "branch_name": "master",
        "match_mode": "exact"
      },
      "config": [
        "./deploy_master.sh"
      ],
      "postion": 1
    }
  ],
  "setup_commands": [
    "nvm install 6"
  ],
  "environment_variables": [
    {
      "name": "env_name_1",
      "value": "foo"
    },
    {
      "name": "env_name_2",
      "value": "bar"
    }
  ],
  "test_pipelines": [
    {
      "name": "Tests",
      "commands": [
        "npm test"
      ]
    }
  ]
}

Responses

Code Datatype

201

Response schema

400

Error

401

Error

403

Error

404

Error

500

Error

Response schema

  • Content type: application/json

  • Response schema type: object

Field name Type

aes_key

string

uuid

string

organization_uuid

string

authentication_user

string

name

string

repository_provider

string

ssh_key

string

repository_url

string

type

string Allowed values: basic, pro

created_at

string

updated_at

string

build_on_pr_only

boolean

branch_match

string Allowed values: include, exclude

branches

array[string]

setup_commands

array[string]

test_pipelines

array[object]

  • id

integer

  • name

string

  • commands

array[string]

team_ids

array[number]

notification_rules

array[object]

  • notifier

string Allowed values: email, slack, campfire, flowdock, webhook

  • target

string Allowed values: all, committer

  • branch

string

  • options

object

key

string

url

string

room

string

  • build_statuses

array[string] Allowed values: started, failed, success, recovered

  • branch_match

string Allowed values: exact, regex, wildcard

environment_variables

array[object]

  • name

string

  • value

string

deployment_pipelines

array[object]

  • id

integer

  • branch

object

branch_name

string

match_mode

string

  • config

object

  • position

integer

Response example

{
    "project": {
        "uuid": "019f9bcc-ce4b-4179-a533-c3995f4b6161",
        "name": "codeship/documentation"
        "type": "basic"
        "repository_url": "https://github.com/codeship/documentation",
        "repository_provider": "github",
        "authentication_user": "CodeShip Bot",
        "organization_uuid": "721cea10-b6a5-0104-5b93-5240c481c5a2",
        "notification_rules": [
            {
                "notifier": "github",
                "branch": null,
                "branch_match": "exact",
                "build_statuses": [
                    "failed",
                    "started",
                    "recovered",
                    "success"
                ],
                "target": "all",
                "options": {}
            },
            {
                "notifier": "email",
                "branch": null,
                "branch_match": "exact",
                "build_statuses": [
                    "failed",
                    "recovered"
                ],
                "target": "all",
                "options": {}
            }
        ],
        "ssh_key": "EXAMPLE ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4AceKnURxK54HXUkxO52SETy7jsQZBV8biE/RtSZukz1uSj1/Y8cm99XGOiQiNnP3KI6KuUnsS/3LNZ0HX/y2Lqraju0Vvkh8Yn6klLEGgsFlNsw5RpS9Cb6CS+iF39tcP+N9s7bPV6a3mEY4Hx30rgTeydj2fcvuTp5gzwQ9c1HBeLq9U2rxcsvDIayHC8T6TeYOh0s33+dKTuZDGD5SzqbLDEMDcRyVsvyzg/GVnpOaJ24dAbD3lxQr4Z/EOBht3wKGuHb/P3L52Pp1mVZrzPpCBt4JBeMu/uGAafywNhIUEYFP0EMh30opiDANe2TBsacN4I7XoUEv0yHM1jYl Codeship/codeship/example",
        "aes_key": null,
        "created_at": "2017-12-07T22:05:52.743Z",
        "updated_at": "2017-12-07T22:05:56.082Z",
        "team_ids": [
          170524,
          202470
        ],
        "setup_commands": [],
        "deployment_pipelines": [],
        "environment_variables": [],
        "test_pipelines": []
    }
}

Code examples

cURL
Go
Java
Node
PHP
Python
Ruby
C#
curl --request POST \
  --url https://api.codeship.com/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects \
  --header 'authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9' \
  --header 'content-type: application/json' \
  --data '{"repository_url":"https://github.com/codeship/documentation.git","type":"basic","team_ids":[99173438,64874098,74618189,92403869],"notification_rules":[{"notifier":"webhook","branch":"development","options":{"url":"https://localhost/webhook"}}],"deployment_pipelines":[{"branch":{"branch_name":"master","match_mode":"exact"},"config":["./deploy_master.sh"],"postion":1}],"setup_commands":["nvm install 6"],"environment_variables":[{"name":"env_name_1","value":"foo"},{"name":"env_name_2","value":"bar"}],"test_pipelines":[{"name":"Tests","commands":["npm test"]}]}'
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.codeship.com/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects"

	payload := strings.NewReader("{\"repository_url\":\"https://github.com/codeship/documentation.git\",\"type\":\"basic\",\"team_ids\":[99173438,64874098,74618189,92403869],\"notification_rules\":[{\"notifier\":\"webhook\",\"branch\":\"development\",\"options\":{\"url\":\"https://localhost/webhook\"}}],\"deployment_pipelines\":[{\"branch\":{\"branch_name\":\"master\",\"match_mode\":\"exact\"},\"config\":[\"./deploy_master.sh\"],\"postion\":1}],\"setup_commands\":[\"nvm install 6\"],\"environment_variables\":[{\"name\":\"env_name_1\",\"value\":\"foo\"},{\"name\":\"env_name_2\",\"value\":\"bar\"}],\"test_pipelines\":[{\"name\":\"Tests\",\"commands\":[\"npm test\"]}]}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("authorization", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9")
	req.Header.Add("content-type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"repository_url\":\"https://github.com/codeship/documentation.git\",\"type\":\"basic\",\"team_ids\":[99173438,64874098,74618189,92403869],\"notification_rules\":[{\"notifier\":\"webhook\",\"branch\":\"development\",\"options\":{\"url\":\"https://localhost/webhook\"}}],\"deployment_pipelines\":[{\"branch\":{\"branch_name\":\"master\",\"match_mode\":\"exact\"},\"config\":[\"./deploy_master.sh\"],\"postion\":1}],\"setup_commands\":[\"nvm install 6\"],\"environment_variables\":[{\"name\":\"env_name_1\",\"value\":\"foo\"},{\"name\":\"env_name_2\",\"value\":\"bar\"}],\"test_pipelines\":[{\"name\":\"Tests\",\"commands\":[\"npm test\"]}]}");
Request request = new Request.Builder()
  .url("https://api.codeship.com/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects")
  .post(body)
  .addHeader("authorization", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9")
  .addHeader("content-type", "application/json")
  .build();

Response response = client.newCall(request).execute();
var http = require("https");

var options = {
  "method": "POST",
  "hostname": "api.codeship.com",
  "port": null,
  "path": "/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects",
  "headers": {
    "authorization": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9",
    "content-type": "application/json"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ repository_url: 'https://github.com/codeship/documentation.git',
  type: 'basic',
  team_ids: [ 99173438, 64874098, 74618189, 92403869 ],
  notification_rules:
   [ { notifier: 'webhook',
       branch: 'development',
       options: { url: 'https://localhost/webhook' } } ],
  deployment_pipelines:
   [ { branch: { branch_name: 'master', match_mode: 'exact' },
       config: [ './deploy_master.sh' ],
       postion: 1 } ],
  setup_commands: [ 'nvm install 6' ],
  environment_variables:
   [ { name: 'env_name_1', value: 'foo' },
     { name: 'env_name_2', value: 'bar' } ],
  test_pipelines: [ { name: 'Tests', commands: [ 'npm test' ] } ] }));
req.end();
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.codeship.com/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"repository_url\":\"https://github.com/codeship/documentation.git\",\"type\":\"basic\",\"team_ids\":[99173438,64874098,74618189,92403869],\"notification_rules\":[{\"notifier\":\"webhook\",\"branch\":\"development\",\"options\":{\"url\":\"https://localhost/webhook\"}}],\"deployment_pipelines\":[{\"branch\":{\"branch_name\":\"master\",\"match_mode\":\"exact\"},\"config\":[\"./deploy_master.sh\"],\"postion\":1}],\"setup_commands\":[\"nvm install 6\"],\"environment_variables\":[{\"name\":\"env_name_1\",\"value\":\"foo\"},{\"name\":\"env_name_2\",\"value\":\"bar\"}],\"test_pipelines\":[{\"name\":\"Tests\",\"commands\":[\"npm test\"]}]}",
  CURLOPT_HTTPHEADER => array(
    "authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.codeship.com")

payload = "{\"repository_url\":\"https://github.com/codeship/documentation.git\",\"type\":\"basic\",\"team_ids\":[99173438,64874098,74618189,92403869],\"notification_rules\":[{\"notifier\":\"webhook\",\"branch\":\"development\",\"options\":{\"url\":\"https://localhost/webhook\"}}],\"deployment_pipelines\":[{\"branch\":{\"branch_name\":\"master\",\"match_mode\":\"exact\"},\"config\":[\"./deploy_master.sh\"],\"postion\":1}],\"setup_commands\":[\"nvm install 6\"],\"environment_variables\":[{\"name\":\"env_name_1\",\"value\":\"foo\"},{\"name\":\"env_name_2\",\"value\":\"bar\"}],\"test_pipelines\":[{\"name\":\"Tests\",\"commands\":[\"npm test\"]}]}"

headers = {
    'authorization': "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9",
    'content-type': "application/json"
    }

conn.request("POST", "/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.codeship.com/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["authorization"] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9'
request["content-type"] = 'application/json'
request.body = "{\"repository_url\":\"https://github.com/codeship/documentation.git\",\"type\":\"basic\",\"team_ids\":[99173438,64874098,74618189,92403869],\"notification_rules\":[{\"notifier\":\"webhook\",\"branch\":\"development\",\"options\":{\"url\":\"https://localhost/webhook\"}}],\"deployment_pipelines\":[{\"branch\":{\"branch_name\":\"master\",\"match_mode\":\"exact\"},\"config\":[\"./deploy_master.sh\"],\"postion\":1}],\"setup_commands\":[\"nvm install 6\"],\"environment_variables\":[{\"name\":\"env_name_1\",\"value\":\"foo\"},{\"name\":\"env_name_2\",\"value\":\"bar\"}],\"test_pipelines\":[{\"name\":\"Tests\",\"commands\":[\"npm test\"]}]}"

response = http.request(request)
puts response.read_body
var client = new RestClient("https://api.codeship.com/v2/organizations/721cea10-b6a5-0104-5b93-5240c481c5a2/projects");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9");
request.AddParameter("application/json", "{\"repository_url\":\"https://github.com/codeship/documentation.git\",\"type\":\"basic\",\"team_ids\":[99173438,64874098,74618189,92403869],\"notification_rules\":[{\"notifier\":\"webhook\",\"branch\":\"development\",\"options\":{\"url\":\"https://localhost/webhook\"}}],\"deployment_pipelines\":[{\"branch\":{\"branch_name\":\"master\",\"match_mode\":\"exact\"},\"config\":[\"./deploy_master.sh\"],\"postion\":1}],\"setup_commands\":[\"nvm install 6\"],\"environment_variables\":[{\"name\":\"env_name_1\",\"value\":\"foo\"},{\"name\":\"env_name_2\",\"value\":\"bar\"}],\"test_pipelines\":[{\"name\":\"Tests\",\"commands\":[\"npm test\"]}]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);