---
title: Create a Slack integration
description: Create a Datadog-Slack integration.
breadcrumbs: Docs > API > Create a Slack integration
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/llms.txt).

# Create a Slack integration

## v1 (deprecated)

| Datadog site      | API endpoint                                                |
| ----------------- | ----------------------------------------------------------- |
| 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 |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v1/integration/slack      |
| 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 |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/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  |

### 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.

{% tabs %}
{% tab label="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 label="Example" %}
```json
{
  "service_hooks": [
    {
      "account": "joe.doe",
      "url": "https://hooks.slack.com/services/example-workspace/example-channel/example-token"
    }
  ]
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="204" %}
OK
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
Error response object.

| Field               | Type     | Description                          |
| ------------------- | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Authentication error

{% tabs %}
{% tab label="Model" %}
Error response object.

| Field               | Type     | Description                          |
| ------------------- | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
Error response object.

| Field               | Type     | Description                          |
| ------------------- | -------- | ------------------------------------ |
| errors [*required*] | [string] | Array of errors returned by the API. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v1/integration/slack" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "service_hooks": [
    {
      "account": "Main_Account",
      "url": "https://hooks.slack.com/services/1/1/1"
    }
  ]
}
EOF
```
{% /tab %}

{% tab label="Ruby [legacy]" %}
```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://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=ruby-legacy) and then save the example to `example.rb` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
```
{% /tab %}
{% /tabs %}
