# Zapier

## Getting Started

All of our API endpoints relating to our endpoints start with the same base URL:

```
https://api.countercyclical.io/v1
```

*See the* [*example*](https://docs.countercyclical.io/~/changes/ZwrMx5xpgOpgFGNOVADb/developers/authentication#example) *in our API documentation above for more information*

## Authentication

{% hint style="warning" %}
An API key is required in order to authenticate successfully between Zapier & Countercyclical. Please visit our Integrations page on the platform to generate your Zapier-specific API key: <https://dashboard.countercyclical.io/settings/workspace/integrations>

*This API is scoped purely to Zapier & cannot be used on any of Countercyclical's other publicly available API endpoints (otherwise a* `401 Unauthorized` *response will be sent back)*
{% endhint %}

### Connecting Zapier & Countercyclical

<mark style="color:green;">`GET`</mark> `/integrations/zapier/auth`

Authenticate with Zapier on Countercyclical

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Body**

| Name     | Type   | Description                                                                                                                          |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `apiKey` | string | API key generated in the [zapier](https://docs.countercyclical.io/guides/integrations/zapier "mention") integration on our platform. |

**Response**

{% tabs %}
{% tab title="2xx" %}

```json
{
  "success": true,
  "emailAddress": "name@example.com",
  "activeWorkspace": "Workspace Name",
}
```

{% endtab %}

{% tab title="4xx" %}

```json
{
  "error": "Invalid or inactive API key"
}
```

{% endtab %}

{% tab title="5xx" %}

```json
{
  "error": "Server error validating API key"
}
```

{% endtab %}
{% endtabs %}

## Triggers

{% hint style="info" %}
Triggers are an event in Countercyclical (e.g., an Investment being created) that initiates a workflow in Zapier.

Learn more about Triggers in [Zapier's Help Center](https://help.zapier.com/hc/en-us/articles/8496288188429-Set-up-your-Zap-trigger)
{% endhint %}

### Investments

<mark style="color:green;">`GET`</mark> `/integrations/zapier/triggers/investments`

Kicks off a [Zap](https://help.zapier.com/hc/en-us/articles/8496309697421-Create-Zaps) in Zapier based on an Investment created in your workspace.

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Query Parameters**

| Name     | Type   | Description                                                                                                                          |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `apiKey` | string | API key generated in the [zapier](https://docs.countercyclical.io/guides/integrations/zapier "mention") integration on our platform. |

**Response**

{% tabs %}
{% tab title="2xx" %}
*Returns an array of* [investments](https://docs.countercyclical.io/developers/endpoints/investments "mention") *in your Workspace.*

```json
[
  {
    "id": "abc1234...",
    ...
  }
]
```

{% endtab %}

{% tab title="4xx" %}

```json
{
  "error": "Invalid request."
}
```

{% endtab %}

{% tab title="5xx" %}

```json
{
  "error": "Server error validating API key"
}
```

{% endtab %}
{% endtabs %}

## Actions

{% hint style="info" %}
Actions in Zapier are a task that is performed as part of the workflow (e.g., creating an Investment in Countercyclical)

Learn more about Actions in [Zapier's Help Center](https://help.zapier.com/hc/en-us/articles/8496257774221-Set-up-your-Zap-action)
{% endhint %}

### Investments

#### Create a New Investment

<mark style="color:green;">`POST`</mark> `/integrations/zapier/actions/investments`

Creates a new Investment in your Countercyclical Workspace

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Query Parameters**

| Name     | Value                                                                                                                                |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `apiKey` | API key generated in the [zapier](https://docs.countercyclical.io/guides/integrations/zapier "mention") integration on our platform. |

**Body**

<table><thead><tr><th>Name</th><th>Required</th><th width="178">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>tickerSymbol</code></td><td><mark style="color:green;">Yes</mark></td><td>string</td><td>The ticker symbol for a publicly-traded company (following <a href="https://www.nasdaqtrader.com/Trader.aspx?id=CQSSymbolConvention">NASDAQ Symbology</a> is recommended for best results)</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="2xx" %}
*Returns the* [investments](https://docs.countercyclical.io/developers/endpoints/investments "mention") *created from your Zapier Action.*

```json
[
  {
    "id": "abc1234...",
    ...
  }
]
```

{% endtab %}

{% tab title="4xx" %}

```json
{
  "error": "Invalid request."
}
```

{% endtab %}

{% tab title="5xx" %}

```json
{
  "error": "Server error validating API key"
}
```

{% endtab %}
{% endtabs %}
