Skip to main content
Use the Terraform provider to manage Xquik resources with your infrastructure code. Platform teams can review account monitors, HMAC webhooks, API keys, and drafts. They can also review tweet actions, profile updates, and support workflows. Each review uses the same state process.

Install

Install from the Terraform Registry. Declare the provider.
Run terraform init before planning or applying resources.

Authenticate

Use variables or environment variables for credentials.
Prefer environment variables for credentials. If you pass credentials through Terraform variables, mark them sensitive = true. In that case, also use an encrypted remote state backend.

Tweet monitor workflow to signed webhooks

Use this workflow when Terraform should own a production tweet monitor and webhook endpoint. The endpoint receives signed events. They feed queues, incident tools, social listening dashboards, or CRM enrichment. The provider resources map to the REST API. x-twitter-scraper_monitor creates an account monitor through POST /monitors. x-twitter-scraper_webhook creates a signed webhook through POST /webhooks. Both resources use Terraform snake_case arguments that map to the API request fields.

Request mapping

Monitor resource

Terraform resource x-twitter-scraper_monitor maps to POST /monitors. It requires username and event_types and accepts optional is_active. It returns id, x_user_id, is_active, and created_at in state.

Webhook resource

Terraform resource x-twitter-scraper_webhook maps to POST /webhooks. It requires url and event_types and accepts optional is_active. It returns id, secret, and created_at in state.

Event data source

Terraform data source x-twitter-scraper_event reads one stored monitor event. It requires id and returns type, username, monitor_id, occurred_at, x_event_id, and data.
Tweet event types include tweet.new, tweet.reply, tweet.quote, and tweet.retweet. Create Monitor lists every type. Webhook URLs must use HTTPS and be reachable from the public internet.

Returned data & handoff

Operators may need to pause, update, or delete the monitor through Terraform. After terraform apply, hand them monitor_id. Hand webhook_id to delivery dashboards and support playbooks. Store webhook_secret in a secret manager. Use it to verify X-Xquik-Signature, X-Xquik-Timestamp, and X-Xquik-Nonce on every delivery.Production webhook payloads include deliveryId and streamEventId. Store deliveryId for receiver idempotency. Store streamEventId when monitor events need exactly-once processing across retries or endpoint changes. Use GET /webhooks/{id}/deliveries to inspect retry state by webhook after apply. Synthetic webhook.test requests verify signing only. They omit those production idempotency fields.Webhook operations are free. Active monitors check every second and cost 30 credits per monitor-hour. Creating one requires the credits of the first monitor hour. Monitors may pause when credits run out.

State & secrets

Terraform state can contain the webhook secret returned at creation time. Use an encrypted backend and restrict state access. Mark every output that references the secret as sensitive = true. If you lose or expose the secret, delete and recreate the webhook. Terraform then receives a new signing secret.

Workflow to declare media tweets and replies

Use x-twitter-scraper_x_tweet when a reviewed infrastructure apply must create one durable tweet or reply. The resource maps to POST /x/tweets and accepts public media URLs in media. It stores the confirmed tweet_id in Terraform state.

Tweet resource mapping

Tweet resource

Terraform resource x-twitter-scraper_x_tweet maps to POST /x/tweets. It requires account and accepts optional text, reply_to_tweet_id, is_note_tweet, and media. It returns tweet_id plus tweet details that state only reads.

Media boundary

The media argument is for public image URLs or exactly 1 public MP4 URL. Text-only tweets and replies cost 30 credits. Attached media adds 2 credits per started MB. Do not pass uploaded media IDs to this resource. They expire 24 hours after upload, and Terraform has no upload resource.
Generated provider docs may list media_ids on x-twitter-scraper_x_tweet. Use media with public image or MP4 URLs for tweets. Uploaded media IDs expire after 24 hours, so keep them out of Terraform state. Send them through REST, MCP tools, or a generated SDK.

Tweet handoff

After terraform apply, hand off tweet_id, reply_to_tweet_id, account, and the original media URLs. They go to the system that needs to reconcile the post. That can be a queue, release record, CRM note, or incident timeline. Keep the media URLs in your own system. That way, a later state refresh does not become the only audit trail.Terraform state for x-twitter-scraper_x_tweet does not expose durable write action fields. It does not expose media upload resources or resources that send direct messages either. A worker may need to store lifecycle handoffs or returned DM message_id. It may also need to upload local media for one-item DM media_ids. In those cases, use the REST API, MCP tools, or a generated SDK.

Error handling

Terraform prints provider errors during plan and apply. REST API response semantics match the error handling guide.

State & pagination

Terraform tracks resource state in your configured backend. Data sources and resources use the generated provider schema. Review the generated docs in the provider repository before adding resources to production state. Do not hand off extraction files through Terraform. Write reply, follower, or tweet search exports as CSV, JSON, XLSX, or JSON Lines. Do it with the REST extraction endpoints, CLI, MCP tools, or generated SDKs. Reserve Terraform state for lasting resources and IDs that need plan and apply review.

Webhooks & references