# 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](/guides/integrations/zapier.md) 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](/guides/integrations/zapier.md) integration on our platform. |

**Response**

{% tabs %}
{% tab title="2xx" %}
*Returns an array of* [Investments](/developers/endpoints/investments.md) *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](/guides/integrations/zapier.md) 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](/developers/endpoints/investments.md) *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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.countercyclical.io/developers/endpoints/integrations/zapier.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
