Add/Delete rules

POST /2/tweets/search/stream/rules

Add or delete rules from a user's active rule set. Users can provide unique, optionally tagged rules to add. Users can delete their entire rule set or a subset specified by rule ids or values.

Query parameters

  • dry_run boolean

    Dry Run can be used with both the add and delete action, with the expected result given, but without actually taking any action in the system (meaning the end state will always be as it was when the request was submitted). This is particularly useful to validate rule changes.

Body object Required

One of:

Responses

  • default

    The request has failed.

    Hide response attributes Show response attributes object
    • code integer(int32) Required
    • message string Required
  • 200

    The request was successful

    Hide response attributes Show response attributes object
    • data array[object]

      A user-provided stream filtering rule.

      Hide data attributes Show data attributes array[object]
      • value string Required

        The filterlang value of the rule.

      • tag string

        A tag meant for the labeling of user provided rules.

      • id string

        Unique identifier of this rule.

        Format should match the following pattern: ^[0-9]{1,19}$.

    • meta object Required
      Hide meta attributes Show meta attributes object
      • summary object

        One of:
      • sent string Required
    • errors array[object]

      An HTTP Problem Details object, as defined in IETF RFC 7807 (https://tools.ietf.org/html/rfc7807).

      Hide errors attributes Show errors attributes array[object]
      • type string Required
      • title string Required
      • detail string
      • status integer
POST /2/tweets/search/stream/rules
curl \
 -X POST https://api.twitter.com/2/tweets/search/stream/rules \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"add":[{"value":"coffee -is:retweet","tag":"Non-retweeted coffee tweets"}]}'
Request examples
{
  "add": [
    {
      "value": "coffee -is:retweet",
      "tag": "Non-retweeted coffee tweets"
    }
  ]
}
{
  "delete": {
    "ids": [
      "120897978112909812"
    ],
    "values": [
      "coffee -is:retweet"
    ]
  }
}
Request examples
{
  "add": [
    {
      "value": "coffee -is:retweet",
      "tag": "Non-retweeted coffee tweets"
    }
  ]
}
{
  "delete": {
    "ids": [
      "120897978112909812"
    ],
    "values": [
      "coffee -is:retweet"
    ]
  }
}
Response examples (default)
{
  "code": 42,
  "message": "string"
}
Response examples (default)
{
  "code": 42,
  "message": "string"
}
Response examples (200)
{
  "data": [
    {
      "value": "coffee -is:retweet",
      "tag": "Non-retweeted coffee tweets",
      "id": "120897978112909812"
    }
  ],
  "meta": {
    "sent": "string",
    "summary": {
      "created": 1,
      "not_created": 1,
      "valid": 1,
      "invalid": 1
    }
  },
  "errors": [
    {
      "type": "string",
      "title": "string",
      "detail": "string",
      "status": 42
    }
  ]
}
Response examples (200)
{
  "data": [
    {
      "value": "coffee -is:retweet",
      "tag": "Non-retweeted coffee tweets",
      "id": "120897978112909812"
    }
  ],
  "meta": {
    "summary": {
      "created": 1,
      "not_created": 1,
      "valid": 1,
      "invalid": 1
    },
    "sent": "string"
  },
  "errors": [
    {
      "type": "string",
      "title": "string",
      "detail": "string",
      "status": 42
    }
  ]
}