# Connect a platform

URL: https://docs.sparklayer.io/ignite/api/new-platform-connection
Operation: `POST /v1/{siteEnv}/{siteId}` (operationId `createPlatformConnection`)
OpenAPI spec: https://docs.sparklayer.io/openapi/ignite.yaml

The SparkLayer Ignite platform will call this endpoint when the merchant connects SparkLayer on the specific platform. Please note that this endpoint must be idempotent as it may be called multiple times.

`POST /v1/{siteEnv}/{siteId}`

> This is an Ignite endpoint: your integration service implements it and SparkLayer calls it.

### Request SparkLayer sends

```http
POST /v1/live/bobs-store HTTP/1.1
Host: ignite.example.com
Content-Type: application/json

{
  "store_id": "1234",
  "spark_api_client_id": "ca7cf4ac-51cb-4836-9a79-d425afc6e280",
  "spark_api_client_secret": "puwUwJZRfsnpB7nENulMW67prs94QYbu2DXHL3Sh",
  "extra_config": {
    "woocommerce_api_key": "<woocommerce_api_key>",
    "woocommerce_api_secret": "<woocommerce_api_secret>",
    "woocommerce_basic_user": "<woocommerce_basic_user>",
    "woocommerce_basic_pass": "<woocommerce_basic_pass>"
  },
  "magento_consumer_key": "<magento_consumer_key>",
  "magento_consumer_secret": "<magento_consumer_secret>",
  "magento_access_token": "<magento_access_token>",
  "magento_access_token_secret": "<magento_access_token_secret>"
}
```

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `siteEnv` | string | Yes | The SparkLayer environment the request is for, such as `live`. Store it, with the site ID, when SparkLayer connects your platform. Example: `live` |
| `siteId` | string | Yes | The SparkLayer site ID the request is for, such as `bobs-store`. Store it, with the environment, when SparkLayer connects your platform. Length: min 1. Example: `bobs-store` |

### Request body (`application/json`) (required)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `store_id` | string | Yes | The ID of the store on the 3rd party platform |
| `spark_api_client_id` | string | Yes | |
| `spark_api_client_secret` | string | Yes | |
| `extra_config` | object \| null | | WooCommerce only. The credentials SparkLayer uses to call the merchant's WooCommerce REST API. |
| `extra_config.woocommerce_api_key` | string \| null | | |
| `extra_config.woocommerce_api_secret` | string \| null | | |
| `extra_config.woocommerce_basic_user` | string \| null | | |
| `extra_config.woocommerce_basic_pass` | string \| null | | |
| `magento_consumer_key` | string \| null | | Magento only |
| `magento_consumer_secret` | string \| null | | Magento only |
| `magento_access_token` | string \| null | | Magento only |
| `magento_access_token_secret` | string \| null | | Magento only |

```json
{
  "store_id": "1234",
  "spark_api_client_id": "ca7cf4ac-51cb-4836-9a79-d425afc6e280",
  "spark_api_client_secret": "puwUwJZRfsnpB7nENulMW67prs94QYbu2DXHL3Sh",
  "extra_config": {
    "woocommerce_api_key": "<woocommerce_api_key>",
    "woocommerce_api_secret": "<woocommerce_api_secret>",
    "woocommerce_basic_user": "<woocommerce_basic_user>",
    "woocommerce_basic_pass": "<woocommerce_basic_pass>"
  },
  "magento_consumer_key": "<magento_consumer_key>",
  "magento_consumer_secret": "<magento_consumer_secret>",
  "magento_access_token": "<magento_access_token>",
  "magento_access_token_secret": "<magento_access_token_secret>"
}
```

### Responses your service returns

#### 201: Successful operation - App install pending

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `redirect_url` | string | Yes | Platform store app install URL to redirect the merchant to in order to complete the connection |

```json
{
  "redirect_url": "https://store-1234.example.io/install"
}
```

#### 204: Successful operation - App already installed - Platform connection is now active

#### 401: Auth Failure

#### 500: System Exception
