# Instagram DMs Automation (`deepanshusharm/instagram-dms-automation`)

Instagram DM Automation
Automatically send direct messages to multiple Instagram users using your session ID. Customize the message, delay, proxy settings, and number of users for safe, efficient outreach.

- **URL**: https://beta-securitybyobscurity.apify.com/deepanshusharm/instagram-dms-automation.md
- **Developed by:** [Deepanshu Sharma](https://beta-securitybyobscurity.apify.com/deepanshusharm) (community)
- **Categories:** Automation, Lead generation, Social media
- **Stats:** 135 total users, 18 monthly users, 100.0% runs succeeded, 14 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$22.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

# README

## Instagram DM Automation

Automatically send personalized direct messages (DMs) to multiple Instagram users using this Apify Actor!

This Actor helps you perform safe and efficient outreach by allowing you to customize your message, set delays between messages, configure proxy settings, and control how many users you target.

***

### How It Works

The Actor logs into Instagram using your **Session ID** and sends your custom message to each username you specify in the input.\
You can configure the delay between each message to avoid triggering Instagram’s anti-spam systems.

***

### Input Parameters

| Field | Type | Description |
| :--- | :--- | :--- |
| `sessionid` | String | Your Instagram session ID for authentication. (Required for login) |
| `target_usernames` | Array of Strings | List of Instagram usernames you want to message. |
| `message` | String | The direct message you want to send. |
| `delay_between_messages` | Integer | Delay between messages (in seconds). Default is 60 seconds. |
| `proxy` | Object | Proxy configuration. (Default: Apify Residential proxies) |
| `max_users` | Integer | Maximum number of users to message. Set to `0` for unlimited messaging. |

***

### Example Input

```json
{
  "sessionid": "your-instagram-sessionid-here",
  "target_usernames": ["user1", "user2", "user3"],
  "message": "Hey! Just wanted to reach out :)",
  "delay_between_messages": 45,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  },
  "max_users": 100
}

```

***

### Example Output

```json

{
  "username": "example_user",
  "user_id": "12345678",
  "thread_id": "87654321",
  "status": "success",
  "message": "Hello, this is my message!"
}

```

⚠️ Important Warnings

Ensure your Instagram account follows Instagram's DM limits to avoid or getting banned (5 per run , 30-40 max user per day).

Always use a reasonable delay between messages!
If you send DMs too quickly without a proper delay (like sending every second), Instagram may detect spam-like behavior.
This can result in:

Temporary action blocks (can't DM or perform actions for hours or days)

Temporary account suspension

Permanent account ban

Avoid messaging a large number of users at once without delays!
Attempting to send DMs to hundreds or thousands of users quickly can seriously risk your Instagram account being flagged, limited, or banned.

Use proxies for added safety.
Proxies (especially Residential proxies) help hide your real IP address and reduce the chance of detection by Instagram.

Your Session ID must stay valid.
If your session expires (you log out everywhere, reset password, or Instagram detects suspicious activity), you will need to generate a new session ID.

Use responsibly!
Always comply with Instagram’s Terms of Service. This Actor is intended for ethical, respectful communication only, not for spam or unsolicited mass messaging.

# Actor input Schema

## `sessionid` (type: `string`):

Your Instagram session ID (required for authentication)

## `target_usernames` (type: `array`):

List of Instagram usernames to message (required)

## `message` (type: `string`):

Message to send to users

## `delay_between_messages` (type: `integer`):

Delay between messages to avoid rate limits

## `proxy` (type: `object`):

HTTP proxy configuration (recommended to use residential proxies)

## `max_users` (type: `integer`):

Maximum number of users to message (0 for unlimited)

## Actor input object example

```json
{
  "sessionid": "70177092341%3AyAG7hiRDY0Qk0h%3A13%3AAYfO_FSFD4tVlpGa4-LaoJPXwMIPQ-e0ATu_rcpdHQ",
  "target_usernames": [
    "humorspot69"
  ],
  "message": "Hello this is an automated message",
  "delay_between_messages": 60,
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  },
  "max_users": 0
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "proxy": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "US"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("deepanshusharm/instagram-dms-automation").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "proxy": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US",
    } }

# Run the Actor and wait for it to finish
run = client.actor("deepanshusharm/instagram-dms-automation").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "proxy": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}' |
apify call deepanshusharm/instagram-dms-automation --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=deepanshusharm/instagram-dms-automation",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Instagram DMs Automation",
        "description": "Instagram DM Automation\nAutomatically send direct messages to multiple Instagram users using your session ID. Customize the message, delay, proxy settings, and number of users for safe, efficient outreach.",
        "version": "0.0",
        "x-build-id": "IalcweCZNXlZ72Eot"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/deepanshusharm~instagram-dms-automation/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-deepanshusharm-instagram-dms-automation",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/deepanshusharm~instagram-dms-automation/runs": {
            "post": {
                "operationId": "runs-sync-deepanshusharm-instagram-dms-automation",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/deepanshusharm~instagram-dms-automation/run-sync": {
            "post": {
                "operationId": "run-sync-deepanshusharm-instagram-dms-automation",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "sessionid",
                    "target_usernames",
                    "message"
                ],
                "properties": {
                    "sessionid": {
                        "title": "Session ID (Required)",
                        "type": "string",
                        "description": "Your Instagram session ID (required for authentication)",
                        "default": "70177092341%3AyAG7hiRDY0Qk0h%3A13%3AAYfO_FSFD4tVlpGa4-LaoJPXwMIPQ-e0ATu_rcpdHQ"
                    },
                    "target_usernames": {
                        "title": "Target Usernames",
                        "minItems": 1,
                        "type": "array",
                        "description": "List of Instagram usernames to message (required)",
                        "default": [
                            "humorspot69"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "message": {
                        "title": "Message",
                        "type": "string",
                        "description": "Message to send to users",
                        "default": "Hello this is an automated message"
                    },
                    "delay_between_messages": {
                        "title": "Delay Between Messages (seconds)",
                        "type": "integer",
                        "description": "Delay between messages to avoid rate limits",
                        "default": 60
                    },
                    "proxy": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "HTTP proxy configuration (recommended to use residential proxies)"
                    },
                    "max_users": {
                        "title": "Maximum Users",
                        "type": "integer",
                        "description": "Maximum number of users to message (0 for unlimited)",
                        "default": 0
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
