-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathdelete_subscription.py
More file actions
34 lines (25 loc) · 1016 Bytes
/
delete_subscription.py
File metadata and controls
34 lines (25 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Delete Activity Subscription - X API v2
========================================
Endpoint: DELETE https://api.x.com/2/activity/subscriptions/:id
Docs: https://docs.x.com/x-api/activity/introduction
Deletes an activity subscription. Once deleted, events matching that subscription
will no longer be delivered to the stream or associated webhook. Use
list_subscriptions.py to find the subscription_id you wish to remove.
Authentication: Bearer Token (App-only)
Required env vars: BEARER_TOKEN
"""
import os
import json
from xdk import Client
bearer_token = os.environ.get("BEARER_TOKEN")
client = Client(bearer_token=bearer_token)
# Replace with the subscription ID you wish to delete.
# You can find subscription IDs by running list_subscriptions.py
subscription_id = "your-subscription-id"
def main():
response = client.activity.delete_subscription(subscription_id)
print("Response code: 200")
print(json.dumps(response.data, indent=4, sort_keys=True))
if __name__ == "__main__":
main()