Twitter/X Compliance API
Endpoints related to keeping X data in your systems compliant
Endpoints related to keeping X data in your systems compliant
openapi: 3.0.0
info:
description: X API v2 available endpoints
version: '2.166'
title: X API v2 Account Activity Compliance API
termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
contact:
name: X Developers
url: https://developer.x.com/
license:
name: X Developer Agreement and Policy
url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
- description: X API
url: https://api.x.com
tags:
- name: Compliance
description: Endpoints related to keeping X data in your systems compliant
externalDocs:
description: Find out more
url: https://developer.twitter.com/en/docs/twitter-api/compliance/batch-tweet/introduction
paths:
/2/compliance/jobs:
get:
security:
- BearerToken: []
tags:
- Compliance
summary: Get Compliance Jobs
description: Retrieves a list of Compliance Jobs filtered by job type and optional status.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs
operationId: getComplianceJobs
parameters:
- name: type
in: query
description: Type of Compliance Job to list.
required: true
schema:
type: string
enum:
- tweets
- users
style: form
- name: status
in: query
description: Status of Compliance Job to list.
required: false
schema:
type: string
enum:
- created
- in_progress
- failed
- complete
style: form
- $ref: '#/components/parameters/ComplianceJobFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2ComplianceJobsResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
post:
security:
- BearerToken: []
tags:
- Compliance
summary: Create Compliance Job
description: Creates a new Compliance Job for the specified job type.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/post-compliance-jobs
operationId: createComplianceJobs
parameters: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateComplianceJobRequest'
required: true
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/CreateComplianceJobResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/compliance/jobs/{id}:
get:
security:
- BearerToken: []
tags:
- Compliance
summary: Get Compliance Job by ID
description: Retrieves details of a specific Compliance Job by its ID.
externalDocs:
url: https://developer.twitter.com/en/docs/twitter-api/compliance/batch-compliance/api-reference/get-compliance-jobs-id
operationId: getComplianceJobsById
parameters:
- name: id
in: path
description: The ID of the Compliance Job to retrieve.
required: true
schema:
$ref: '#/components/schemas/JobId'
style: simple
- $ref: '#/components/parameters/ComplianceJobFieldsParameter'
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/Get2ComplianceJobsIdResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
/2/likes/compliance/stream:
get:
security:
- BearerToken: []
tags:
- Compliance
summary: Stream Likes compliance data
description: Streams all compliance data related to Likes for Users.
operationId: streamLikesCompliance
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Likes Compliance events will be provided.
required: false
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Likes Compliance events will be provided.
required: false
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/LikesComplianceStreamResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
x-twitter-streaming: true
/2/tweets/compliance/stream:
get:
security:
- BearerToken: []
tags:
- Compliance
summary: Stream Posts compliance data
description: Streams all compliance data related to Posts.
operationId: streamPostsCompliance
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: partition
in: query
description: The partition number.
required: true
schema:
type: integer
minimum: 1
maximum: 4
format: int32
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Post Compliance events will be provided.
required: false
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Post Compliance events will be provided.
required: false
example: '2021-02-14T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/TweetComplianceStreamResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
x-twitter-streaming: true
/2/tweets/label/stream:
get:
security:
- BearerToken: []
tags:
- Compliance
summary: Stream Post labels
description: Streams all labeling events applied to Posts.
operationId: streamLabelsCompliance
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Post labels will be provided.
required: false
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Post labels will be provided.
required: false
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/TweetLabelStreamResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
x-twitter-streaming: true
/2/users/compliance/stream:
get:
security:
- BearerToken: []
tags:
- Compliance
summary: Stream Users compliance data
description: Streams all compliance data related to Users.
operationId: streamUsersCompliance
parameters:
- name: backfill_minutes
in: query
description: The number of minutes of backfill requested.
required: false
schema:
type: integer
minimum: 0
maximum: 5
format: int32
style: form
- name: partition
in: query
description: The partition number.
required: true
schema:
type: integer
minimum: 1
maximum: 4
format: int32
style: form
- name: start_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the User Compliance events will be provided.
required: false
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
- name: end_time
in: query
description: YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the User Compliance events will be provided.
required: false
example: '2021-02-01T18:40:40.000Z'
schema:
type: string
format: date-time
style: form
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/UserComplianceStreamResponse'
default:
description: The request has failed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
x-twitter-streaming: true
components:
schemas:
UserDeleteComplianceSchema:
type: object
required:
- user_delete
properties:
user_delete:
$ref: '#/components/schemas/UserComplianceSchema'
DownloadUrl:
type: string
description: URL from which the user will retrieve their compliance results.
format: uri
UploadExpiration:
type: string
description: Expiration time of the upload URL.
format: date-time
example: '2021-01-06T18:40:40.000Z'
TweetLabelData:
description: Tweet label data.
oneOf:
- $ref: '#/components/schemas/TweetNoticeSchema'
- $ref: '#/components/schemas/TweetUnviewableSchema'
UserId:
type: string
description: Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
pattern: ^[0-9]{1,19}$
example: '2244994945'
UserComplianceSchema:
type: object
required:
- user
- event_at
properties:
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
user:
type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/UserId'
TweetEditComplianceObjectSchema:
type: object
required:
- tweet
- event_at
- initial_tweet_id
- edit_tweet_ids
properties:
edit_tweet_ids:
type: array
minItems: 1
items:
$ref: '#/components/schemas/TweetId'
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
initial_tweet_id:
$ref: '#/components/schemas/TweetId'
tweet:
type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/TweetId'
TweetComplianceData:
description: Tweet compliance data.
oneOf:
- $ref: '#/components/schemas/TweetDeleteComplianceSchema'
- $ref: '#/components/schemas/TweetWithheldComplianceSchema'
- $ref: '#/components/schemas/TweetDropComplianceSchema'
- $ref: '#/components/schemas/TweetUndropComplianceSchema'
- $ref: '#/components/schemas/TweetEditComplianceSchema'
UserSuspendComplianceSchema:
type: object
required:
- user_suspend
properties:
user_suspend:
$ref: '#/components/schemas/UserComplianceSchema'
UserTakedownComplianceSchema:
type: object
required:
- user
- withheld_in_countries
- event_at
properties:
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
user:
type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/UserId'
withheld_in_countries:
type: array
minItems: 1
items:
$ref: '#/components/schemas/CountryCode'
TweetComplianceStreamResponse:
description: Tweet compliance stream events.
oneOf:
- type: object
description: Compliance event.
required:
- data
properties:
data:
$ref: '#/components/schemas/TweetComplianceData'
- type: object
required:
- errors
properties:
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
TweetWithheldComplianceSchema:
type: object
required:
- withheld
properties:
withheld:
$ref: '#/components/schemas/TweetTakedownComplianceSchema'
UserUnsuspendComplianceSchema:
type: object
required:
- user_unsuspend
properties:
user_unsuspend:
$ref: '#/components/schemas/UserComplianceSchema'
TweetTakedownComplianceSchema:
type: object
required:
- tweet
- withheld_in_countries
- event_at
properties:
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
quote_tweet_id:
$ref: '#/components/schemas/TweetId'
tweet:
type: object
required:
- id
- author_id
properties:
author_id:
$ref: '#/components/schemas/UserId'
id:
$ref: '#/components/schemas/TweetId'
withheld_in_countries:
type: array
minItems: 1
items:
$ref: '#/components/schemas/CountryCode'
UserProtectComplianceSchema:
type: object
required:
- user_protect
properties:
user_protect:
$ref: '#/components/schemas/UserComplianceSchema'
TweetEditComplianceSchema:
type: object
required:
- tweet_edit
properties:
tweet_edit:
$ref: '#/components/schemas/TweetEditComplianceObjectSchema'
Problem:
type: object
description: An HTTP Problem Details object, as defined in IETF RFC 7807 (https://tools.ietf.org/html/rfc7807).
required:
- type
- title
properties:
detail:
type: string
status:
type: integer
title:
type: string
type:
type: string
discriminator:
propertyName: type
mapping:
about:blank: '#/components/schemas/GenericProblem'
https://api.twitter.com/2/problems/client-disconnected: '#/components/schemas/ClientDisconnectedProblem'
https://api.twitter.com/2/problems/client-forbidden: '#/components/schemas/ClientForbiddenProblem'
https://api.twitter.com/2/problems/conflict: '#/components/schemas/ConflictProblem'
https://api.twitter.com/2/problems/disallowed-resource: '#/components/schemas/DisallowedResourceProblem'
https://api.twitter.com/2/problems/duplicate-rules: '#/components/schemas/DuplicateRuleProblem'
https://api.twitter.com/2/problems/invalid-request: '#/components/schemas/InvalidRequestProblem'
https://api.twitter.com/2/problems/invalid-rules: '#/components/schemas/InvalidRuleProblem'
https://api.twitter.com/2/problems/noncompliant-rules: '#/components/schemas/NonCompliantRulesProblem'
https://api.twitter.com/2/problems/not-authorized-for-field: '#/components/schemas/FieldUnauthorizedProblem'
https://api.twitter.com/2/problems/not-authorized-for-resource: '#/components/schemas/ResourceUnauthorizedProblem'
https://api.twitter.com/2/problems/operational-disconnect: '#/components/schemas/OperationalDisconnectProblem'
https://api.twitter.com/2/problems/resource-not-found: '#/components/schemas/ResourceNotFoundProblem'
https://api.twitter.com/2/problems/resource-unavailable: '#/components/schemas/ResourceUnavailableProblem'
https://api.twitter.com/2/problems/rule-cap: '#/components/schemas/RulesCapProblem'
https://api.twitter.com/2/problems/streaming-connection: '#/components/schemas/ConnectionExceptionProblem'
https://api.twitter.com/2/problems/unsupported-authentication: '#/components/schemas/UnsupportedAuthenticationProblem'
https://api.twitter.com/2/problems/usage-capped: '#/components/schemas/UsageCapExceededProblem'
Get2ComplianceJobsIdResponse:
type: object
properties:
data:
$ref: '#/components/schemas/ComplianceJob'
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
ComplianceJobName:
type: string
description: User-provided name for a compliance job.
maxLength: 64
example: my-job
ComplianceJob:
type: object
required:
- id
- type
- created_at
- upload_url
- download_url
- upload_expires_at
- download_expires_at
- status
properties:
created_at:
$ref: '#/components/schemas/CreatedAt'
download_expires_at:
$ref: '#/components/schemas/DownloadExpiration'
download_url:
$ref: '#/components/schemas/DownloadUrl'
id:
$ref: '#/components/schemas/JobId'
name:
$ref: '#/components/schemas/ComplianceJobName'
status:
$ref: '#/components/schemas/ComplianceJobStatus'
type:
$ref: '#/components/schemas/ComplianceJobType'
upload_expires_at:
$ref: '#/components/schemas/UploadExpiration'
upload_url:
$ref: '#/components/schemas/UploadUrl'
TweetUndropComplianceSchema:
type: object
required:
- undrop
properties:
undrop:
$ref: '#/components/schemas/TweetComplianceSchema'
LikeComplianceSchema:
type: object
required:
- delete
properties:
delete:
$ref: '#/components/schemas/UnlikeComplianceSchema'
ResultCount:
type: integer
description: The number of results returned in this response.
format: int32
UserProfileModificationComplianceSchema:
type: object
required:
- user_profile_modification
properties:
user_profile_modification:
$ref: '#/components/schemas/UserProfileModificationObjectSchema'
UserScrubGeoSchema:
type: object
required:
- scrub_geo
properties:
scrub_geo:
$ref: '#/components/schemas/UserScrubGeoObjectSchema'
TweetLabelStreamResponse:
description: Tweet label stream events.
oneOf:
- type: object
description: Tweet Label event.
required:
- data
properties:
data:
$ref: '#/components/schemas/TweetLabelData'
- type: object
required:
- errors
properties:
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
UserScrubGeoObjectSchema:
type: object
required:
- user
- up_to_tweet_id
- event_at
properties:
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
up_to_tweet_id:
$ref: '#/components/schemas/TweetId'
user:
type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/UserId'
UserUnprotectComplianceSchema:
type: object
required:
- user_unprotect
properties:
user_unprotect:
$ref: '#/components/schemas/UserComplianceSchema'
LikesComplianceStreamResponse:
description: Likes compliance stream events.
oneOf:
- type: object
description: Compliance event.
required:
- data
properties:
data:
$ref: '#/components/schemas/LikeComplianceSchema'
- type: object
required:
- errors
properties:
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
ComplianceJobStatus:
type: string
description: Status of a compliance job.
enum:
- created
- in_progress
- failed
- complete
- expired
ComplianceJobType:
type: string
description: Type of compliance job to list.
enum:
- tweets
- users
CreateComplianceJobResponse:
type: object
properties:
data:
$ref: '#/components/schemas/ComplianceJob'
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
TweetUnviewable:
type: object
required:
- tweet
- event_at
- application
properties:
application:
type: string
description: If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’.
example: apply
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
tweet:
type: object
required:
- id
- author_id
properties:
author_id:
$ref: '#/components/schemas/UserId'
id:
$ref: '#/components/schemas/TweetId'
TweetNotice:
type: object
required:
- tweet
- event_type
- event_at
- application
properties:
application:
type: string
description: If the label is being applied or removed. Possible values are ‘apply’ or ‘remove’.
example: apply
details:
type: string
description: Information shown on the Tweet label
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
event_type:
type: string
description: The type of label on the Tweet
example: misleading
extended_details_url:
type: string
description: Link to more information about this kind of label
label_title:
type: string
description: Title/header of the Tweet label
tweet:
type: object
required:
- id
- author_id
properties:
author_id:
$ref: '#/components/schemas/UserId'
id:
$ref: '#/components/schemas/TweetId'
DownloadExpiration:
type: string
description: Expiration time of the download URL.
format: date-time
example: '2021-01-06T18:40:40.000Z'
UserComplianceData:
description: User compliance data.
oneOf:
- $ref: '#/components/schemas/UserProtectComplianceSchema'
- $ref: '#/components/schemas/UserUnprotectComplianceSchema'
- $ref: '#/components/schemas/UserDeleteComplianceSchema'
- $ref: '#/components/schemas/UserUndeleteComplianceSchema'
- $ref: '#/components/schemas/UserSuspendComplianceSchema'
- $ref: '#/components/schemas/UserUnsuspendComplianceSchema'
- $ref: '#/components/schemas/UserWithheldComplianceSchema'
- $ref: '#/components/schemas/UserScrubGeoSchema'
- $ref: '#/components/schemas/UserProfileModificationComplianceSchema'
TweetId:
type: string
description: Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
pattern: ^[0-9]{1,19}$
example: '1346889436626259968'
JobId:
type: string
description: Compliance Job ID.
pattern: ^[0-9]{1,19}$
example: '1372966999991541762'
UserWithheldComplianceSchema:
type: object
required:
- user_withheld
properties:
user_withheld:
$ref: '#/components/schemas/UserTakedownComplianceSchema'
UserComplianceStreamResponse:
description: User compliance stream events.
oneOf:
- type: object
description: User compliance event.
required:
- data
properties:
data:
$ref: '#/components/schemas/UserComplianceData'
- type: object
required:
- errors
properties:
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
Get2ComplianceJobsResponse:
type: object
properties:
data:
type: array
minItems: 1
items:
$ref: '#/components/schemas/ComplianceJob'
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/Problem'
meta:
type: object
properties:
result_count:
$ref: '#/components/schemas/ResultCount'
UploadUrl:
type: string
description: URL to which the user will upload their Tweet or user IDs.
format: uri
UserProfileModificationObjectSchema:
type: object
required:
- user
- profile_field
- new_value
- event_at
properties:
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
new_value:
type: string
profile_field:
type: string
user:
type: object
required:
- id
properties:
id:
$ref: '#/components/schemas/UserId'
CreateComplianceJobRequest:
type: object
description: A request to create a new batch compliance job.
required:
- type
properties:
name:
$ref: '#/components/schemas/ComplianceJobName'
resumable:
type: boolean
description: If true, this endpoint will return a pre-signed URL with resumable uploads enabled.
type:
type: string
description: Type of compliance job to list.
enum:
- tweets
- users
TweetUnviewableSchema:
type: object
required:
- public_tweet_unviewable
properties:
public_tweet_unviewable:
$ref: '#/components/schemas/TweetUnviewable'
CountryCode:
type: string
description: A two-letter ISO 3166-1 alpha-2 country code.
pattern: ^[A-Z]{2}$
example: US
TweetComplianceSchema:
type: object
required:
- tweet
- event_at
properties:
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
quote_tweet_id:
$ref: '#/components/schemas/TweetId'
tweet:
type: object
required:
- id
- author_id
properties:
author_id:
$ref: '#/components/schemas/UserId'
id:
$ref: '#/components/schemas/TweetId'
TweetDropComplianceSchema:
type: object
required:
- drop
properties:
drop:
$ref: '#/components/schemas/TweetComplianceSchema'
CreatedAt:
type: string
description: Creation time of the compliance job.
format: date-time
example: '2021-01-06T18:40:40.000Z'
UnlikeComplianceSchema:
type: object
required:
- favorite
- event_at
properties:
event_at:
type: string
description: Event time.
format: date-time
example: '2021-07-06T18:40:40.000Z'
favorite:
type: object
required:
- id
- user_id
properties:
id:
$ref: '#/components/schemas/TweetId'
user_id:
$ref: '#/components/schemas/UserId'
TweetNoticeSchema:
type: object
required:
- public_tweet_notice
properties:
public_tweet_notice:
$ref: '#/components/schemas/TweetNotice'
UserUndeleteComplianceSchema:
type: object
required:
- user_undelete
properties:
user_undelete:
$ref: '#/components/schemas/UserComplianceSchema'
TweetDeleteComplianceSchema:
type: object
required:
- delete
properties:
delete:
$ref: '#/components/schemas/TweetComplianceSchema'
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
parameters:
ComplianceJobFieldsParameter:
name: compliance_job.fields
in: query
description: A comma separated list of ComplianceJob fields to display.
required: false
schema:
type: array
description: The fields available for a ComplianceJob object.
minItems: 1
uniqueItems: true
items:
type: string
enum:
- created_at
- download_expires_at
- download_url
- id
- name
- resumable
# --- truncated at 32 KB (34 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/twitter-x/refs/heads/main/openapi/twitter-x-compliance-api-openapi.yml