---
title: "Create Connection"
method: POST
path: "/connections/{projectId}"
tags: ["Connections"]
---

# Create Connection

`POST /connections/{projectId}`

## Request

- Base URL: `https://partner.peaka.studio/api/v1`
- URL: `https://partner.peaka.studio/api/v1/connections/{projectId}`
- Auth: HTTP bearer

This endpoint allows you to create a new connection for a specified project.

You need to provide the project ID and the connection details in the request body.

The connection details include the name, type, and credentials required for the connection.

Depending on the connection type, additional parameters may be required under credentials.

You can view the list of supported connection types by calling the /connections/config endpoint.

You can switch examples from the second dropdown of the sample request component. (cURL (first dropdown) - Stripe Connection Request (second dropdown))

**Note**: Typically, the connection creation process involves the following steps:
1. First, learn about the connection type and the required parameters by calling the /connections/config endpoint.
2. Create a connection request with the required parameters.
3. If the connection requires Oauth2 authorization, there may be additional steps to follow. See https://docs.peaka.com/how-to-guides/how-to-create-oauth2-based-connections-via-peaka for more information.

**Example**:
- POSTGRES Connection Configuration:

GET /connections/config endpoint displays all of the connection types.

GET /connections/config/POSTGRES endpoint displays the POSTGRES connection configuration.

The definition of the POSTGRES connection configuration is as follows:
``` json
    {
        "connectionType": "POSTGRES",
        "connectionTypeLabel": "PostgreSQL",
        "name": "PostgreSQL",
        "authorizationType": "custom",
        "credentialSchemaType": "postgres_credential_schema",
        "category": "Database",
        "configuration": [
            {
                "fieldName": "url",
                "fieldType": "text",
                "required": true,
                "description": "URL"
            },
            {
                "fieldName": "port",
                "fieldType": "number",
                "required": true,
                "description": "Port"
            },
            {
                "fieldName": "user",
                "fieldType": "text",
                "required": true,
                "description": "User"
            },
            {
                "fieldName": "password",
                "fieldType": "text",
                "required": true,
                "description": "Password"
            },
            {
                "fieldName": "databaseName",
                "fieldType": "text",
                "required": true,
                "description": "Database Name"
            },
            {
                "fieldName": "useSsl",
                "fieldType": "boolean",
                "required": true,
                "description": "Use SSL"
            }
        ],
        "documentationUrl": "https://docs.peaka.com/integrations/postgresql"
    }
```

The request's `type` takes the configuration's `connectionType` value (`POSTGRES` here); `connectionType` is also accepted as the field name.

According to the POSTGRES connection configuration, the connection request should include the following parameters (respecting to the required flag):
- url: URL of the host IP or domain
- port: Port number
- user: User of the database
- password: Password of the user
- databaseName: Name of the database
- useSsl: Boolean value to indicate whether to use SSL

``` json
{
    "name": "examplePostgre",
    "type": "POSTGRES",
    "credential": {
        "url": "<host ip or domain>",
        "port": 5432,
        "user": "userOfYourDB",
        "password": "passwordOfUser",
        "databaseName": "yourDBName",
        "useSsl": false
    }
}
```

## Path parameters

- `projectId` string, required

## Request body

- ConnectionRequest
  - `name` string: Name of the connection given by the user
  - `type` string: Type of the connection: the `connectionType` value /connections/config returns for it, e.g. `stripe`, `airtable`, `ORACLE`. `connectionType` is accepted as another name for this field.
  - `credential` object: Credential object for the connection. Its structure is dependent on the connection type and can be fetched by following url: /connections/config
  - `connectionCallback` string: The url to redirect to after an oauth connection is established.

## Response `200`

Connection created successfully

- Connection
  - `id` string: Connection ID
  - `name` string: Name of the connection
  - `type` string: Type of connection. Example: airtable for AirTable, stripe for Stripe, hubspot_access_token for HubSpot (with Access Token), etc. Exact list can be fetched by following url: /connections/config
  - `url` string: Oauth callback url if the connection is Oauth based.

---

[API](https://skmtc.dev/peaka/apis/peaka-gateway-api.md) · [All operations](https://skmtc.dev/peaka/apis/peaka-gateway-api/llms.txt) · [OpenAPI document](https://skmtc.dev/peaka/apis/peaka-gateway-api/revisions/e68b033a22d5?raw)
