# Subscription

Subscription status and activation. Require Privy JWT.

## Get subscription status

> Returns the current user's subscription tier, expiry date, current price,\
> and the treasury address to send payment to.\
> \
> Use the \`treasury\` address and \`price\` to construct the \`usdSend\` EIP-712\
> payload for activating a subscription.<br>

```json
{"openapi":"3.1.0","info":{"title":"Zirodelta API","version":"1.0.0"},"tags":[{"name":"Subscription","description":"Subscription status and activation. Require Privy JWT."}],"servers":[{"url":"https://api.dex.zirodelta.xyz","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Privy-issued JWT. Obtain by connecting your wallet at https://app.zirodelta.com."}},"headers":{"X-RateLimit-Limit":{"description":"Maximum requests allowed in the current rate limit window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests remaining in the current rate limit window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp (seconds) when the current rate limit window resets.","schema":{"type":"integer"}}},"schemas":{"SubscriptionStatus":{"type":"object","required":["tier","price","treasury"],"properties":{"tier":{"type":"string","enum":["free","pro"],"description":"Current subscription tier."},"expires_at":{"type":"string","format":"date-time","nullable":true,"description":"Pro expiry timestamp. Null for free tier."},"price":{"type":"string","description":"Current subscription price in USDC (as string matching the on-chain amount)."},"treasury":{"type":"string","description":"Zirodelta treasury address to send payment to via usdSend."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error description."},"retry_after":{"type":"integer","description":"Seconds to wait before retrying. Present only on 429 responses."}}}},"responses":{"Unauthorized":{"description":"Missing or invalid JWT.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"TooManyRequests":{"description":"Rate limit exceeded.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/subscription":{"get":{"operationId":"getSubscription","summary":"Get subscription status","description":"Returns the current user's subscription tier, expiry date, current price,\nand the treasury address to send payment to.\n\nUse the `treasury` address and `price` to construct the `usdSend` EIP-712\npayload for activating a subscription.\n","tags":["Subscription"],"responses":{"200":{"description":"Subscription status.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionStatus"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/TooManyRequests"},"503":{"description":"Database unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Activate Pro subscription

> Activates or extends a Pro subscription by submitting an on-chain payment.\
> \
> \*\*Flow:\*\*\
> 1\. Call GET /api/subscription to get \`price\` and \`treasury\` address.\
> 2\. Sign a \`usdSend\` EIP-712 typed data message in the user's wallet:\
> &#x20;  \- \`destination\`: treasury address from step 1\
> &#x20;  \- \`amount\`: price string from step 1 (e.g. "10.0")\
> &#x20;  \- \`time\`: current Unix timestamp in milliseconds (serves as nonce)\
> 3\. POST the signature, amount, and time to this endpoint.\
> 4\. The backend submits the \`usdSend\` to Hyperliquid and grants 30 days of Pro.\
> \
> If the user already has an active Pro subscription, the 30 days are added to the\
> existing expiry date.<br>

```json
{"openapi":"3.1.0","info":{"title":"Zirodelta API","version":"1.0.0"},"tags":[{"name":"Subscription","description":"Subscription status and activation. Require Privy JWT."}],"servers":[{"url":"https://api.dex.zirodelta.xyz","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Privy-issued JWT. Obtain by connecting your wallet at https://app.zirodelta.com."}},"headers":{"X-RateLimit-Limit":{"description":"Maximum requests allowed in the current rate limit window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests remaining in the current rate limit window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp (seconds) when the current rate limit window resets.","schema":{"type":"integer"}}},"schemas":{"SubscriptionStatus":{"type":"object","required":["tier","price","treasury"],"properties":{"tier":{"type":"string","enum":["free","pro"],"description":"Current subscription tier."},"expires_at":{"type":"string","format":"date-time","nullable":true,"description":"Pro expiry timestamp. Null for free tier."},"price":{"type":"string","description":"Current subscription price in USDC (as string matching the on-chain amount)."},"treasury":{"type":"string","description":"Zirodelta treasury address to send payment to via usdSend."}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error description."},"retry_after":{"type":"integer","description":"Seconds to wait before retrying. Present only on 429 responses."}}}},"responses":{"BadRequest":{"description":"Invalid request parameters or body.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"Missing or invalid JWT.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"TooManyRequests":{"description":"Rate limit exceeded.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"InternalError":{"description":"Internal server error.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/api/subscription/activate":{"post":{"operationId":"activateSubscription","summary":"Activate Pro subscription","description":"Activates or extends a Pro subscription by submitting an on-chain payment.\n\n**Flow:**\n1. Call GET /api/subscription to get `price` and `treasury` address.\n2. Sign a `usdSend` EIP-712 typed data message in the user's wallet:\n   - `destination`: treasury address from step 1\n   - `amount`: price string from step 1 (e.g. \"10.0\")\n   - `time`: current Unix timestamp in milliseconds (serves as nonce)\n3. POST the signature, amount, and time to this endpoint.\n4. The backend submits the `usdSend` to Hyperliquid and grants 30 days of Pro.\n\nIf the user already has an active Pro subscription, the 30 days are added to the\nexisting expiry date.\n","tags":["Subscription"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["signature","amount","time"],"properties":{"signature":{"type":"string","description":"65-byte EIP-712 signature hex string (from eth_signTypedData_v4), including the 0x prefix."},"amount":{"type":"string","description":"USDC amount as a string. Must match the current subscription price."},"time":{"type":"integer","format":"int64","description":"Unix timestamp in milliseconds used as the usdSend nonce when signing."}}}}}},"responses":{"200":{"description":"Subscription activated. Returns updated subscription status.","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["sub"],"properties":{"sub":{"$ref":"#/components/schemas/SubscriptionStatus"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalError"},"502":{"description":"Payment submission to Hyperliquid failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zirodelta.com/api-reference/subscription.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
