---
title: Create a Slack integration
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Slack Integration
---

# Create a Slack integration{% #create-a-slack-integration %}

{% tab title="v1" %}

| Datadog site      | API endpoint                                                |
| ----------------- | ----------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v1/integration/slack |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v1/integration/slack |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v1/integration/slack      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v1/integration/slack      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v1/integration/slack  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v1/integration/slack     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v1/integration/slack |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v1/integration/slack |

### Overview



Create a Datadog-Slack integration. Once created, add a channel to it with the [Add channels to Slack integration endpoint](https://docs.datadoghq.com/api.md?lang=bash#add-channels-to-slack-integration).

This method updates your integration configuration by **adding** your new configuration to the existing one in your Datadog organization.



### Request

#### Body Data (required)

Create Datadog-Slack integration request body.

{% tab title="Model" %}

| Parent field  | Field                     | Type     | Description                        |
| ------------- | ------------------------- | -------- | ---------------------------------- |
|               | service_hooks             | [object] | The array of service hook objects. |
| service_hooks | account [*required*] | string   | Your Slack account name.           |
| service_hooks | url [*required*]     | string   | Your Slack service hook URL.       |

{% /tab %}

{% tab title="Example" %}

```json
{
  "service_hooks": [
    {
      "account": "joe.doe",
      "url": "https://hooks.slack.com/services/example-workspace/example-channel/example-token"
    }
  ]
}
```

{% /tab %}

### Response

{% tab title="204" %}
OK
{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Authentication error
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
Error response object.

| Field                    | Type     | Description                          |
| ------------------------ | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v1/integration/slack" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "service_hooks": [
    {
      "account": "Main_Account",
      "url": "https://hooks.slack.com/services/1/1/1"
    }
  ]
}
EOF 
                
##### 

```ruby
require 'rubygems'
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

config= {
    "service_hooks": [
      {
        "account": "Main_Account",
        "url": "https://hooks.slack.com/services/1/1/1"
      },
      {
        "account": "doghouse",
        "url": "https://hooks.slack.com/services/2/2/2"
      }
    ]
  }

dog = Dogapi::Client.new(api_key, app_key)

dog.create_integration('slack', config)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby-legacy) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
{% /tab %}
