> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Check X API Credit Top-up Payment Status API

> Poll a credit checkout session for pending, paid, expired, or failed status before starting tweet, follower, monitor, or write requests. See examples.

<Panel>
  <Tabs defaultTabIndex={0} sync={false}>
    <Tab title="200" id="response-credits-topup-status-200">
      ```json theme={null}
      {
        "amount_dollars": 25,
        "credits": "166666",
        "status": "paid"
      }
      ```
    </Tab>

    <Tab title="400" id="response-credits-topup-status-400">
      ```json theme={null}
      {
        "error": "invalid_input",
        "message": "Invalid input. Check the request body."
      }
      ```
    </Tab>

    <Tab title="401" id="response-credits-topup-status-401">
      ```json theme={null}
      {
        "error": "unauthenticated",
        "message": "Authentication required. Provide a valid API key or bearer token."
      }
      ```
    </Tab>

    <Tab title="404" id="response-credits-topup-status-404">
      ```json theme={null}
      {
        "error": "not_found",
        "message": "Resource not found."
      }
      ```
    </Tab>

    <Tab title="429" id="response-credits-topup-status-429">
      ```json theme={null}
      {
        "error": "rate_limit_exceeded",
        "message": "Too many requests. Try again later.",
        "retryAfter": 60
      }
      ```
    </Tab>
  </Tabs>
</Panel>

<blockquote className="agent-llms-directive">
  For the complete documentation index, see <a href="/llms.txt">llms.txt</a>.
</blockquote>

<Callout icon="circle-check" color="#16a34a">
  **Free** - does not consume credits
</Callout>

Use this endpoint after creating a standard [top-up checkout](/api-reference/credits/topup). Pass the checkout session ID for that top-up to check whether payment is complete.

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://xquik.com/api/v1/credits/topup/status?session_id=checkout_session_id" \
    -H "x-api-key: xq_YOUR_KEY_HERE" | jq
  ```

  ```javascript Node.js theme={null}
  const sessionId = "checkout_session_id";
  const response = await fetch(
    `https://xquik.com/api/v1/credits/topup/status?session_id=${encodeURIComponent(sessionId)}`,
    { headers: { "x-api-key": "xq_YOUR_KEY_HERE" } },
  );
  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://xquik.com/api/v1/credits/topup/status",
      headers={"x-api-key": "xq_YOUR_KEY_HERE"},
      params={"session_id": "checkout_session_id"},
  )
  data = response.json()
  print(data)
  ```

  ```go Go theme={null}
  package main

  import (
      "encoding/json"
      "fmt"
      "net/http"
      "net/url"
  )

  func main() {
      endpoint, err := url.Parse("https://xquik.com/api/v1/credits/topup/status")
      if err != nil {
          panic(err)
      }
      query := endpoint.Query()
      query.Set("session_id", "checkout_session_id")
      endpoint.RawQuery = query.Encode()

      req, err := http.NewRequest("GET", endpoint.String(), nil)
      if err != nil {
          panic(err)
      }
      req.Header.Set("x-api-key", "xq_YOUR_KEY_HERE")

      resp, err := http.DefaultClient.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      var data map[string]interface{}
      if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
          panic(err)
      }
      fmt.Println(data)
  }
  ```
</CodeGroup>

## Gate Queued API Work on the Checkout Result

Store the checkout session ID when creating a standard top-up. Associate it
with the intended tweet, follower, reply, monitor, or write workload. Never
substitute a session from another account or purchase.

Poll this endpoint before releasing credit-dependent work. Interpret the
returned status as a state machine:

* `processing` keeps the workload paused.
* `paid` allows a fresh credit-balance check.
* `failed` requires a new checkout.
* `expired` requires a new checkout.

Do not start work from `amount_dollars` or `credits` alone. Only `paid`
confirms that credits were granted. Then call
[Get Credits](/api-reference/credits/get). Compare the balance with the planned
request cost.

Keep processing polls bounded. Wait between requests and honor
`Retry-After` after rate limiting. Several rapid polls cannot accelerate the
payment result.

Store the last observed status and check time with the session ID. This lets
another worker resume polling without creating a second purchase.

Handle terminal states explicitly. A failed or expired checkout must not be
retried as though payment were still processing. Create a new checkout only
after the user or approved billing workflow requests it.

When `paid` appears, release only the workload tied to that checkout. Keep
unrelated queues behind their own credit and approval checks. This prevents
one top-up from silently authorizing broader activity.

## Headers

<ParamField header="x-api-key" type="string" required>
  Your API key. Session cookie authentication is also supported.
</ParamField>

## Query parameters

<ParamField query="session_id" type="string" required>
  Checkout session ID for the top-up checkout.
</ParamField>

## Response

### 200 Paid

Payment succeeded. Credits have been added to the account.

<ResponseField name="status" type="string">Always `"paid"`.</ResponseField>
<ResponseField name="amount_dollars" type="integer">Dollar amount requested for the top-up.</ResponseField>
<ResponseField name="credits" type="string">Credit amount granted as a Bigint string.</ResponseField>

```json theme={null}
{
  "amount_dollars": 25,
  "credits": "166666",
  "status": "paid"
}
```

### 200 Processing

Payment has not reached a final state yet. Poll again later.

<ResponseField name="status" type="string">Always `"processing"`.</ResponseField>
<ResponseField name="amount_dollars" type="integer">Dollar amount requested for the top-up, when available.</ResponseField>
<ResponseField name="credits" type="string">Pending credit amount as a Bigint string, when available.</ResponseField>

```json theme={null}
{
  "amount_dollars": 25,
  "credits": "166666",
  "status": "processing"
}
```

### 200 Failed

Payment failed. Create a new top-up checkout before retrying payment.

<ResponseField name="status" type="string">Always `"failed"`.</ResponseField>

```json theme={null}
{
  "status": "failed"
}
```

### 200 Expired

The checkout session expired before payment completed.

<ResponseField name="status" type="string">Always `"expired"`.</ResponseField>

```json theme={null}
{
  "status": "expired"
}
```

### 400 Invalid input

```json theme={null}
{ "error": "invalid_input" }
```

The `session_id` query parameter is missing.

### 401 Unauthenticated

```json theme={null}
{ "error": "unauthenticated" }
```

Missing or invalid API key.

### 404 Not found

```json theme={null}
{ "error": "not_found" }
```

No top-up checkout exists for that session ID on this account.

### 429 Rate Limited

```json theme={null}
{ "error": "rate_limit_exceeded", "message": "Too many requests. Try again later.", "retryAfter": 1 }
```

Too many requests. Wait for the `Retry-After` header before retrying.

<Note>
  **Related:** [Top Up Credits](/api-reference/credits/topup) · [Quick Top-Up](/api-reference/credits/quick-topup) · [Get Credits](/api-reference/credits/get) · [Billing Guide](/guides/billing)
</Note>
