# Get a connection

> One connection, with every sync, workflow, API proxy and scheduled task that uses it and whether it can be deleted. Never its credentials.

Source: https://docs.stacksync.com/api-reference/connections/get_connection

`GET https://api.stacksync.com/v1/workspaces/{workspace_id}/connections/{connection_id}`

- Operation: `get_connection`
- Resource: Connections
- Access: read-only

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | integer | Yes | The workspace. List the ones your key can reach with GET /v1/workspaces. |
| `connection_id` | string (uuid) | Yes | The connection. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `region` | string (besg \| usnv) | Yes | Region of the connection: besg or usnv |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object (ConnectionWithUsage) | Yes |  |
| `data.connection_id` | string | Yes |  |
| `data.connection_name` | string | Yes |  |
| `data.app_type` | string | Yes | The type shown in Stacksync |
| `data.is_shared_with_workspace` | boolean | Yes |  |
| `data.created_time` | string | Yes | UTC, YYYY-MM-DD HH:MM:SS |
| `data.last_modified_time` | string | Yes | UTC, YYYY-MM-DD HH:MM:SS |
| `data.credentials_options` | object | Yes | The identifiers of the connection (instance_id, instance_url, shop_name, sub_domain...), never a secret |
| `data.connection_resource_id` | string \| null | Yes | The name workflow steps reference the connection by |
| `data.region` | string | Yes |  |
| `data.needs_reauthorization` | boolean | Yes | True when Stacksync marked the credentials invalid (the app refused to refresh them): reauthorize it in Stacksync. Credentials the app refuses on a read are reported by that read |
| `data.used_in_syncs` | array of object (ConnectionSync) | Yes |  |
| `data.used_in_syncs[].sync_id` | string | Yes |  |
| `data.used_in_syncs[].sync_name` | string | Yes |  |
| `data.used_in_workflows` | array of object (ConnectionWorkflow) | Yes |  |
| `data.used_in_workflows[].workflow_id` | string | Yes |  |
| `data.used_in_workflows[].workflow_name` | string | Yes |  |
| `data.used_in_api_proxies` | array of object (ConnectionApiProxy) | Yes |  |
| `data.used_in_api_proxies[].api_proxy_id` | string | Yes |  |
| `data.used_in_api_proxies[].api_proxy_name` | string | Yes |  |
| `data.used_in_tasks` | array of object (ConnectionTask) | Yes |  |
| `data.used_in_tasks[].task_id` | string | Yes |  |
| `data.used_in_tasks[].task_name` | string | Yes |  |
| `data.used_in_tasks[].sync_id` | string \| null | No | The sync of the trigger this task runs, null for a scheduled task |
| `data.used_in_tasks[].trigger_id` | string \| null | No | The sync trigger this task runs, null for a scheduled task |
| `data.can_delete` | boolean | Yes | False while a sync, workflow, API proxy or task uses the connection |

## Example request

```bash
curl -X GET "https://api.stacksync.com/v1/workspaces/{workspace_id}/connections/{connection_id}?region=usnv" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY"
```

## Example response (200)

```json
{
  "data": {
    "connection_id": "<connection_id>",
    "connection_name": "<connection_name>",
    "app_type": "<app_type>",
    "is_shared_with_workspace": false,
    "created_time": "<created_time>",
    "last_modified_time": "<last_modified_time>",
    "credentials_options": {},
    "connection_resource_id": "<connection_resource_id>",
    "region": "<region>",
    "needs_reauthorization": false,
    "used_in_syncs": [
      {
        "sync_id": "<sync_id>",
        "sync_name": "<sync_name>"
      }
    ],
    "used_in_workflows": [
      {
        "workflow_id": "<workflow_id>",
        "workflow_name": "<workflow_name>"
      }
    ],
    "used_in_api_proxies": [
      {
        "api_proxy_id": "<api_proxy_id>",
        "api_proxy_name": "<api_proxy_name>"
      }
    ],
    "used_in_tasks": [
      {
        "task_id": "<task_id>",
        "task_name": "<task_name>",
        "sync_id": "<sync_id>",
        "trigger_id": "<trigger_id>"
      }
    ],
    "can_delete": false
  }
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | Bad Request | `{ "error": string, "msg": string, "field": string \| null }` |
| 403 | Forbidden | `{ "error": string, "msg": string, "field": string \| null }` |
| 404 | Not Found | `{ "error": string, "msg": string, "field": string \| null }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [List connections](https://docs.stacksync.com/api-reference/connections/list_connections)
- [Create a connection](https://docs.stacksync.com/api-reference/connections/create_connection)
- [Update a connection](https://docs.stacksync.com/api-reference/connections/update_connection)
- [Delete a connection](https://docs.stacksync.com/api-reference/connections/delete_connection)
- [Reauthorize a connection](https://docs.stacksync.com/api-reference/connections/reauthorize_connection)