Message Queue
Managed message queue: publish and consume messages, batch, dead-letter queues (DLQ), redrive and push subscriptions.
1. Overview
https://api.infrai.cc/v1/queueAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/queue capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/queue/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"2. Methods (15)
2.1queue.publish
Publish a message to a queue, optionally delayed.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | The queue name. |
payload | object | Required | Message payload. |
delay_seconds | number | Optional | Delay before delivery in seconds.0–604800default: 0 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
{ message_id }| Name | Type | Description |
|---|---|---|
message_id | string | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
queue | string | Queue name this message or subscription belongs to |
acked | boolean | Whether the message was acknowledged (queue.ack response) |
nacked | boolean | Whether the message was rejected (queue.nack response) |
requeue | boolean | Whether the rejected message was requeued (queue.nack response) |
account_id | string | Account identifier that owns this resource |
payload | object | Payload data for the message or request body |
headers | object | null | Custom HTTP headers to include in requests or responses |
status | "available" | "in_flight" | "deleted" | "dlq" | Current status of this resource |
delivery_count | integer | Number of delivery attempts for this message≥ 0 |
visibility_timeout_expires_at | string | null | ISO 8601 timestamp when visibility timeout expiresformat: date-time |
published_at | string | ISO 8601 timestamp when the event was publishedformat: date-time |
available_at | string | ISO 8601 timestamp when the message becomes available for consumptionformat: date-time |
priority | integer | Priority for MX or SRV records0–10default: 0 |
message_group_id | string | null | FIFO only. |
deduplication_id | string | null | FIFO only; 5-min dedup window. |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/publish \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample", "payload": {}}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/publish",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample', 'payload': {}},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/publish",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "payload": {}}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/publish",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "payload": {}}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample", "payload": {}}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/publish", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/publish"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\", \"payload\": {}}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/publish");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\", \"payload\": {}}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/publish");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\", \"payload\": {}}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/publish")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample", "payload": {}}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/publish")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample", "payload": {}}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.2queue.create
创建一个消息队列
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Required | 队列名称3–80 charspattern: ^[a-z0-9._-]+$ |
type | "standard" | "fifo" | Optional | 队列类型:standard 标准 / fifo 先进先出default: "standard" |
dead_letter_queue | string | Optional | 接收失败消息的死信队列名(须已存在) |
max_retries | number | Optional | 转入 DLQ 前允许的 nack 次数≥ 1 |
message_retention_days | number | Optional | 消息保留天数1–30 |
visibility_timeout_default | number | Optional | 默认可见性超时(租约)秒数0–43200 |
enable_priority | boolean | Optional | 是否启用优先级 |
idempotency_key | string | Optional | 幂等键,避免重复创建 |
Returns
QueueRecord { queue, type, dead_letter_queue?, max_retries, visibility_timeout_default }| Name | Type | Description |
|---|---|---|
name | string | Human-readable name for this resource3–80 charspattern: ^[a-z0-9._-]+$ |
type | "standard" | "fifo" | Type discriminator for this resource |
account_id | string | Account identifier that owns this resourcepattern: ^acct_(anon|email)_[A-Za-z0-9_]… |
message_retention_days | integer | Number of days to retain queue messages1–30 |
max_message_size_kb | integer | Maximum message size in kilobytes1–256 |
visibility_timeout_default | integer | Default visibility timeout in seconds.0–43200 |
delivery_delay_seconds | integer | Delay before message delivery in seconds0–900 |
enable_priority | boolean | Whether priority-based delivery is enabled |
dlq_name | string | null | Name of the dead-letter queue |
max_receive_count | integer | Nack count after which message moves to DLQ.≥ 1 |
created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
updated_at | string | ISO 8601 timestamp when this resource was last updatedformat: date-time |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "example"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/create",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'name': 'example'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"name": "example"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"name": "example"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"name": "example"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/create", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/create"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"name\": \"example\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/create");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"name\": \"example\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/create");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"name\": \"example\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/create")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"name": "example"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/create")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"name": "example"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.3queue.get
获取队列配置详情
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
Returns
QueueRecord { queue, type, dead_letter_queue?, max_retries, visibility_timeout_default }| Name | Type | Description |
|---|---|---|
name | string | Human-readable name for this resource3–80 charspattern: ^[a-z0-9._-]+$ |
type | "standard" | "fifo" | Type discriminator for this resource |
account_id | string | Account identifier that owns this resourcepattern: ^acct_(anon|email)_[A-Za-z0-9_]… |
message_retention_days | integer | Number of days to retain queue messages1–30 |
max_message_size_kb | integer | Maximum message size in kilobytes1–256 |
visibility_timeout_default | integer | Default visibility timeout in seconds.0–43200 |
delivery_delay_seconds | integer | Delay before message delivery in seconds0–900 |
enable_priority | boolean | Whether priority-based delivery is enabled |
dlq_name | string | null | Name of the dead-letter queue |
max_receive_count | integer | Nack count after which message moves to DLQ.≥ 1 |
created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
updated_at | string | ISO 8601 timestamp when this resource was last updatedformat: date-time |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/queue/get/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/queue/get/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/get/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/get/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/queue/get/QUEUE", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/get/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/queue/get/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/get/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/get/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/queue/get/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.4queue.list
分页列出所有队列
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | 分页游标,来自上一页 next_cursor |
limit | number | Optional | 每页返回数量 |
Returns
{ items: QueueRecord[], next_cursor? }| Name | Type | Description |
|---|---|---|
items | object[] | Array of result items in this page |
items[].name | string | Human-readable name for this resource3–80 charspattern: ^[a-z0-9._-]+$ |
items[].type | "standard" | "fifo" | Type discriminator for this resource |
items[].account_id | string | Account identifier that owns this resourcepattern: ^acct_(anon|email)_[A-Za-z0-9_]… |
items[].message_retention_days | integer | Number of days to retain queue messages1–30 |
items[].max_message_size_kb | integer | Maximum message size in kilobytes1–256 |
items[].visibility_timeout_default | integer | Default visibility timeout in seconds.0–43200 |
items[].delivery_delay_seconds | integer | Delay before message delivery in seconds0–900 |
items[].enable_priority | boolean | Whether priority-based delivery is enabled |
items[].dlq_name | string | null | Name of the dead-letter queue |
items[].max_receive_count | integer | Nack count after which message moves to DLQ.≥ 1 |
items[].created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
items[].updated_at | string | ISO 8601 timestamp when this resource was last updatedformat: date-time |
next_cursor | string | null | Opaque cursor to fetch the next page; null/absent if this is the last page |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/queue/list \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/queue/list",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/queue/list", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/list"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/queue/list");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/list");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/list")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/queue/list")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.5queue.update
更新队列配置
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
dead_letter_queue | string | Optional | 死信队列名 |
max_retries | number | Optional | 转入 DLQ 前允许的 nack 次数≥ 1 |
message_retention_days | number | Optional | 消息保留天数1–30 |
visibility_timeout_default | number | Optional | 默认可见性超时秒数0–43200 |
enable_priority | boolean | Optional | 是否启用优先级 |
idempotency_key | string | Optional | 幂等键,避免重复执行 |
Returns
QueueRecord { queue, max_retries, visibility_timeout_default }| Name | Type | Description |
|---|---|---|
name | string | Human-readable name for this resource3–80 charspattern: ^[a-z0-9._-]+$ |
type | "standard" | "fifo" | Type discriminator for this resource |
account_id | string | Account identifier that owns this resourcepattern: ^acct_(anon|email)_[A-Za-z0-9_]… |
message_retention_days | integer | Number of days to retain queue messages1–30 |
max_message_size_kb | integer | Maximum message size in kilobytes1–256 |
visibility_timeout_default | integer | Default visibility timeout in seconds.0–43200 |
delivery_delay_seconds | integer | Delay before message delivery in seconds0–900 |
enable_priority | boolean | Whether priority-based delivery is enabled |
dlq_name | string | null | Name of the dead-letter queue |
max_receive_count | integer | Nack count after which message moves to DLQ.≥ 1 |
created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
updated_at | string | ISO 8601 timestamp when this resource was last updatedformat: date-time |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X PATCH https://api.infrai.cc/v1/queue/update/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.patch(
"https://api.infrai.cc/v1/queue/update/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/update/QUEUE",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/update/QUEUE",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{}`)
req, _ := http.NewRequest("PATCH", "https://api.infrai.cc/v1/queue/update/QUEUE", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/update/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString("{}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("PATCH"), "https://api.infrai.cc/v1/queue/update/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/update/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/update/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Patch.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.patch("https://api.infrai.cc/v1/queue/update/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.6queue.delete
删除一个队列
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
idempotency_key | string | Optional | 幂等键,避免重复执行 |
Returns
{ queue, deleted }| Name | Type | Description |
|---|---|---|
queue | string | Name of the (attempted) deleted queue |
deleted | boolean | Whether the queue was deleted |
status | "not_found" | null | Set to 'not_found' when the queue did not exist (deleted=false) |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X DELETE https://api.infrai.cc/v1/queue/delete/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/queue/delete/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/delete/QUEUE",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/delete/QUEUE",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("DELETE", "https://api.infrai.cc/v1/queue/delete/QUEUE", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/delete/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("DELETE"), "https://api.infrai.cc/v1/queue/delete/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/delete/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/delete/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Delete.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.delete("https://api.infrai.cc/v1/queue/delete/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.7queue.purge
清空队列中所有消息
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
idempotency_key | string | Optional | 幂等键,避免重复执行 |
Returns
{ queue, purged }| Name | Type | Description |
|---|---|---|
queue | string | Name of the (attempted) purged queue |
purged | integer | null | Number of messages purged |
found | boolean | Set to false when the queue did not exist (purged omitted) |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/purge/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/purge/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/purge/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/purge/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/purge/QUEUE", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/purge/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/purge/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/purge/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/purge/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/purge/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.8queue.stats
获取队列统计指标
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
Returns
QueueStats { queue, available, in_flight, dlq, oldest_age_seconds? }| Name | Type | Description |
|---|---|---|
queue | string | Queue name this message or subscription belongs to |
message_count | integer | available + in_flight.≥ 0 |
available_count | integer | Number of messages available for consumption≥ 0 |
in_flight_count | integer | Number of messages currently being processed≥ 0 |
delayed_count | integer | Number of delayed messages≥ 0 |
dlq_count | integer | Number of messages in the dead-letter queue≥ 0 |
oldest_message_age_seconds | integer | Age of the oldest message in the queue in seconds≥ 0 |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/queue/stats/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/queue/stats/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/stats/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/stats/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/queue/stats/QUEUE", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/stats/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/queue/stats/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/stats/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/stats/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/queue/stats/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.9queue.publish_batch
批量发布多条消息到队列
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
messages | QueueMessage[] | Required | 待发布的消息数组1–100 items |
idempotency_key | string | Optional | 幂等键,避免重复发布 |
Returns
{ message_ids }| Name | Type | Description |
|---|---|---|
items | object[] | Array of result items in this page |
items[].message_id | string | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
items[].queue | string | Queue name this message or subscription belongs to |
items[].acked | boolean | Whether the message was acknowledged (queue.ack response) |
items[].nacked | boolean | Whether the message was rejected (queue.nack response) |
items[].requeue | boolean | Whether the rejected message was requeued (queue.nack response) |
items[].account_id | string | Account identifier that owns this resource |
items[].payload | object | Payload data for the message or request body |
items[].headers | object | null | Custom HTTP headers to include in requests or responses |
items[].status | "available" | "in_flight" | "deleted" | "dlq" | Current status of this resource |
items[].delivery_count | integer | Number of delivery attempts for this message≥ 0 |
items[].visibility_timeout_expires_at | string | null | ISO 8601 timestamp when visibility timeout expiresformat: date-time |
items[].published_at | string | ISO 8601 timestamp when the event was publishedformat: date-time |
items[].available_at | string | ISO 8601 timestamp when the message becomes available for consumptionformat: date-time |
items[].priority | integer | Priority for MX or SRV records0–10default: 0 |
items[].message_group_id | string | null | FIFO only. |
items[].deduplication_id | string | null | FIFO only; 5-min dedup window. |
next_cursor | string | null | Opaque cursor to fetch the next page; null/absent if this is the last page |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/publish_batch \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample", "messages": [{"payload": {}}]}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/publish_batch",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample', 'messages': [{'payload': {}}]},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/publish_batch",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "messages": [{"payload": {}}]}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/publish_batch",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "messages": [{"payload": {}}]}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample", "messages": [{"payload": {}}]}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/publish_batch", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/publish_batch"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\", \"messages\": [{\"payload\": {}}]}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/publish_batch");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\", \"messages\": [{\"payload\": {}}]}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/publish_batch");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\", \"messages\": [{\"payload\": {}}]}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/publish_batch")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample", "messages": [{"payload": {}}]}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/publish_batch")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample", "messages": [{"payload": {}}]}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.10queue.consume
从队列拉取一批消息消费
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
max_messages | number | Optional | 单次最多拉取的消息数1–100default: 10 |
visibility_timeout | number | Optional | 本批消息的租约秒数;默认取队列配置0–43200 |
Returns
{ messages: QueueMessage[] }| Name | Type | Description |
|---|---|---|
items | object[] | Array of result items in this page |
items[].message_id | string | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
items[].queue | string | Queue name this message or subscription belongs to |
items[].acked | boolean | Whether the message was acknowledged (queue.ack response) |
items[].nacked | boolean | Whether the message was rejected (queue.nack response) |
items[].requeue | boolean | Whether the rejected message was requeued (queue.nack response) |
items[].account_id | string | Account identifier that owns this resource |
items[].payload | object | Payload data for the message or request body |
items[].headers | object | null | Custom HTTP headers to include in requests or responses |
items[].status | "available" | "in_flight" | "deleted" | "dlq" | Current status of this resource |
items[].delivery_count | integer | Number of delivery attempts for this message≥ 0 |
items[].visibility_timeout_expires_at | string | null | ISO 8601 timestamp when visibility timeout expiresformat: date-time |
items[].published_at | string | ISO 8601 timestamp when the event was publishedformat: date-time |
items[].available_at | string | ISO 8601 timestamp when the message becomes available for consumptionformat: date-time |
items[].priority | integer | Priority for MX or SRV records0–10default: 0 |
items[].message_group_id | string | null | FIFO only. |
items[].deduplication_id | string | null | FIFO only; 5-min dedup window. |
next_cursor | string | null | Opaque cursor to fetch the next page; null/absent if this is the last page |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/consume \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/consume",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/consume",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/consume",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/consume", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/consume"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/consume");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/consume");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/consume")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/consume")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.11queue.ack
确认一条已消费的消息
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
message_id | string | Required | 消息 IDpattern: ^qmsg_[A-Za-z0-9]{20,}$ |
idempotency_key | string | Optional | 幂等键,避免重复执行 |
Returns
{ message_id, acked }| Name | Type | Description |
|---|---|---|
message_id | string | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
queue | string | Queue name this message or subscription belongs to |
acked | boolean | Whether the message was acknowledged (queue.ack response) |
nacked | boolean | Whether the message was rejected (queue.nack response) |
requeue | boolean | Whether the rejected message was requeued (queue.nack response) |
account_id | string | Account identifier that owns this resource |
payload | object | Payload data for the message or request body |
headers | object | null | Custom HTTP headers to include in requests or responses |
status | "available" | "in_flight" | "deleted" | "dlq" | Current status of this resource |
delivery_count | integer | Number of delivery attempts for this message≥ 0 |
visibility_timeout_expires_at | string | null | ISO 8601 timestamp when visibility timeout expiresformat: date-time |
published_at | string | ISO 8601 timestamp when the event was publishedformat: date-time |
available_at | string | ISO 8601 timestamp when the message becomes available for consumptionformat: date-time |
priority | integer | Priority for MX or SRV records0–10default: 0 |
message_group_id | string | null | FIFO only. |
deduplication_id | string | null | FIFO only; 5-min dedup window. |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/ack \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample", "message_id": "hello"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/ack",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample', 'message_id': 'hello'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/ack",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "message_id": "hello"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/ack",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "message_id": "hello"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample", "message_id": "hello"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/ack", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/ack"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\", \"message_id\": \"hello\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/ack");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\", \"message_id\": \"hello\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/ack");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\", \"message_id\": \"hello\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/ack")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample", "message_id": "hello"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/ack")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample", "message_id": "hello"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.12queue.nack
否认一条消息,可重新入队或转入死信
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
message_id | string | Required | 消息 IDpattern: ^qmsg_[A-Za-z0-9]{20,}$ |
requeue | boolean | Optional | true 重新入队;false 直接转入死信default: true |
idempotency_key | string | Optional | 幂等键,避免重复执行 |
Returns
{ message_id, nacked, requeued }| Name | Type | Description |
|---|---|---|
message_id | string | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
queue | string | Queue name this message or subscription belongs to |
acked | boolean | Whether the message was acknowledged (queue.ack response) |
nacked | boolean | Whether the message was rejected (queue.nack response) |
requeue | boolean | Whether the rejected message was requeued (queue.nack response) |
account_id | string | Account identifier that owns this resource |
payload | object | Payload data for the message or request body |
headers | object | null | Custom HTTP headers to include in requests or responses |
status | "available" | "in_flight" | "deleted" | "dlq" | Current status of this resource |
delivery_count | integer | Number of delivery attempts for this message≥ 0 |
visibility_timeout_expires_at | string | null | ISO 8601 timestamp when visibility timeout expiresformat: date-time |
published_at | string | ISO 8601 timestamp when the event was publishedformat: date-time |
available_at | string | ISO 8601 timestamp when the message becomes available for consumptionformat: date-time |
priority | integer | Priority for MX or SRV records0–10default: 0 |
message_group_id | string | null | FIFO only. |
deduplication_id | string | null | FIFO only; 5-min dedup window. |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/nack \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample", "message_id": "hello"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/nack",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample', 'message_id': 'hello'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/nack",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "message_id": "hello"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/nack",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "message_id": "hello"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample", "message_id": "hello"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/nack", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/nack"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\", \"message_id\": \"hello\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/nack");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\", \"message_id\": \"hello\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/nack");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\", \"message_id\": \"hello\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/nack")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample", "message_id": "hello"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/nack")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample", "message_id": "hello"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.13queue.dlq.list
分页列出死信队列中的消息
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
cursor | string | Optional | 分页游标,来自上一页 next_cursor |
limit | number | Optional | 每页返回数量 |
Returns
{ items: QueueMessage[], next_cursor? }| Name | Type | Description |
|---|---|---|
items | object[] | Array of result items in this page |
items[].message_id | string | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
items[].queue | string | Queue name this message or subscription belongs to |
items[].acked | boolean | Whether the message was acknowledged (queue.ack response) |
items[].nacked | boolean | Whether the message was rejected (queue.nack response) |
items[].requeue | boolean | Whether the rejected message was requeued (queue.nack response) |
items[].account_id | string | Account identifier that owns this resource |
items[].payload | object | Payload data for the message or request body |
items[].headers | object | null | Custom HTTP headers to include in requests or responses |
items[].status | "available" | "in_flight" | "deleted" | "dlq" | Current status of this resource |
items[].delivery_count | integer | Number of delivery attempts for this message≥ 0 |
items[].visibility_timeout_expires_at | string | null | ISO 8601 timestamp when visibility timeout expiresformat: date-time |
items[].published_at | string | ISO 8601 timestamp when the event was publishedformat: date-time |
items[].available_at | string | ISO 8601 timestamp when the message becomes available for consumptionformat: date-time |
items[].priority | integer | Priority for MX or SRV records0–10default: 0 |
items[].message_group_id | string | null | FIFO only. |
items[].deduplication_id | string | null | FIFO only; 5-min dedup window. |
next_cursor | string | null | Opaque cursor to fetch the next page; null/absent if this is the last page |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/queue/dlq/list/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/queue/dlq/list/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/dlq/list/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/dlq/list/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/queue/dlq/list/QUEUE", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/dlq/list/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/queue/dlq/list/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/dlq/list/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/dlq/list/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/queue/dlq/list/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.14queue.dlq.redrive
将死信消息重投回原队列
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
message_id | string | Optional | 重投单条消息的 ID;省略则批量重投pattern: ^qmsg_[A-Za-z0-9]{20,}$ |
since | string | Optional | 批量重投:该时刻及之后进入死信的全部消息format: date-time |
idempotency_key | string | Optional | 幂等键,避免重复重投 |
Returns
{ queue, redriven }| Name | Type | Description |
|---|---|---|
ok | boolean | Whether the redrive was initiated |
redriven_count | integer | null | Number of messages redriven |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.15queue.push_subscribe
为队列配置推送订阅
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | 队列名称 |
url | string | Required | https 推送目标地址(经 SSRF 校验)format: uri |
secret | string | Optional | 对推送请求做 HMAC 签名的密钥 |
max_retries | number | Optional | 推送失败重试次数≥ 0 |
visibility_timeout | number | Optional | 可见性超时秒数0–43200 |
dead_letter_queue | string | Optional | 死信队列名 |
idempotency_key | string | Optional | 幂等键,避免重复订阅 |
Returns
PushSubscription { subscription_id, queue, url }| Name | Type | Description |
|---|---|---|
subscription_id | string | Unique identifier for this subscriptionpattern: ^sub_[A-Za-z0-9]{20,}$ |
queue | string | Queue name this message or subscription belongs to |
account_id | string | Account identifier that owns this resourcepattern: ^acct_(anon|email)_[A-Za-z0-9_]… |
concurrency | integer | Number of concurrent consumers for push subscriptions≥ 1 |
max_retries | integer | Maximum number of delivery retries≥ 0 |
dead_letter_queue | string | null | Dead-letter queue name for failed messages |
active | boolean | Whether this resource is currently active |
started_at | string | ISO 8601 timestamp when execution startedformat: date-time |
stopped_at | string | null | ISO 8601 timestamp when the subscription was stoppedformat: date-time |
Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/queue/push_subscribe/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample", "url": "https://example.com/callback"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/push_subscribe/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample', 'url': 'https://example.com/callback'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/push_subscribe/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "url": "https://example.com/callback"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/push_subscribe/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample", "url": "https://example.com/callback"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"queue": "sample", "url": "https://example.com/callback"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/queue/push_subscribe/QUEUE", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/queue/push_subscribe/QUEUE"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"queue\": \"sample\", \"url\": \"https://example.com/callback\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/queue/push_subscribe/QUEUE");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"queue\": \"sample\", \"url\": \"https://example.com/callback\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/queue/push_subscribe/QUEUE");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"queue\": \"sample\", \"url\": \"https://example.com/callback\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/queue/push_subscribe/QUEUE")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"queue": "sample", "url": "https://example.com/callback"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/queue/push_subscribe/QUEUE")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"queue": "sample", "url": "https://example.com/callback"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}3. All capabilities
Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.
queue.ackPOST /v1/queue/ackAcknowledge (ack) a consumed message to remove it from the queue.
Parameters (3)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Queue name this message or subscription belongs to |
message_id | string | Required | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.consumePOST /v1/queue/consumePull a batch of messages from a queue for processing.
Parameters (3)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Queue name this message or subscription belongs to |
max_messages | integer | Optional | Maximum number of messages to consume in one batch1–100default: 10 |
visibility_timeout | integer | null | Optional | Lease seconds; defaults to queue's visibility_timeout_default.0–43200 |
queue.createPOST /v1/queue/createCreate a message queue (standard or FIFO, with optional dead-letter queue).
Parameters (8)
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Required | Human-readable name for this resource3–80 charspattern: ^[a-z0-9._-]+$ |
type | "standard" | "fifo" | Optional | Type discriminator for this resourcedefault: "standard" |
dead_letter_queue | string | null | Optional | Name of an existing queue to receive failed messages. |
max_retries | integer | null | Optional | Nack count before moving to DLQ.≥ 1 |
message_retention_days | integer | null | Optional | Number of days to retain queue messages1–30 |
visibility_timeout_default | integer | null | Optional | Default visibility timeout in seconds0–43200 |
enable_priority | boolean | null | Optional | Whether priority-based delivery is enabled |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.deleteDELETE /v1/queue/delete/{queue}Delete a message queue and discard all of its pending messages (use queue.purge to keep the queue); idempotent.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Path parameter. |
queue.dlq.listGET /v1/queue/dlq/list/{queue}List messages in a queue's dead-letter queue (DLQ) with pagination.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Path parameter. |
queue.dlq.redrivePOST /v1/queue/dlq/redrive/{queue}Redrive dead-letter messages back to the source queue, individually or in bulk.
Parameters (4)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Queue name this message or subscription belongs to |
message_id | string | null | Optional | Redrive a single message; omit for bulk.pattern: ^qmsg_[A-Za-z0-9]{20,}$ |
since | string | null | Optional | Bulk redrive all DLQ messages dead-lettered at/after this time.format: date-time |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.getGET /v1/queue/get/{queue}Retrieve a queue's configuration details.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Path parameter. |
queue.listGET /v1/queue/listList all message queues with pagination.
No request parameters.
queue.nackPOST /v1/queue/nackNegatively acknowledge (nack) a message to requeue it or route it to the DLQ.
Parameters (4)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Queue name this message or subscription belongs to |
message_id | string | Required | Unique identifier for this messagepattern: ^qmsg_[A-Za-z0-9]{20,}$ |
requeue | boolean | Optional | false → straight to DLQ.default: true |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.publishPOST /v1/queue/publishPublish a single message to a queue (idempotent).
Parameters (8)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Queue name this message or subscription belongs to |
payload | object | Required | Payload data for the message or request body |
delay_seconds | integer | Optional | 0..604800 (7 days).0–604800default: 0 |
priority | integer | Optional | Priority for MX or SRV records0–9default: 0 |
message_group_id | string | null | Optional | FIFO only. |
deduplication_id | string | null | Optional | FIFO only; 5-min dedup window. |
headers | object | null | Optional | Custom HTTP headers to include in requests or responses |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.publish_batchPOST /v1/queue/publish_batchPublish multiple messages to a queue in a single batch.
Parameters (3)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Queue name this message or subscription belongs to |
messages | object[] | Required | List of messages to publish or process1–100 items |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.purgePOST /v1/queue/purge/{queue}Purge all messages from a queue.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Name of the queue to purge. |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.push_subscribePOST /v1/queue/push_subscribe/{queue}Configure a push subscription to deliver queue messages to a callback URL.
Parameters (7)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Queue name this message or subscription belongs to |
url | string | Required | https:// push target; SSRF-validated.format: uri |
secret | string | null | Optional | HMAC signing secret for pushed deliveries. |
max_retries | integer | null | Optional | Maximum number of delivery retries≥ 0 |
visibility_timeout | integer | null | Optional | Visibility timeout in seconds0–43200 |
dead_letter_queue | string | null | Optional | Dead-letter queue name for failed messages |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
queue.statsGET /v1/queue/stats/{queue}Retrieve queue metrics: available, in-flight, and dead-lettered message counts.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Path parameter. |
queue.updatePATCH /v1/queue/update/{queue}Update a queue's DLQ, retry, and retention settings.
Parameters (7)
| Name | Type | Required | Description |
|---|---|---|---|
queue | string | Required | Path parameter. |
dead_letter_queue | string | null | Optional | Dead-letter queue name for failed messages |
max_retries | integer | null | Optional | Maximum number of delivery retries≥ 1 |
message_retention_days | integer | null | Optional | Number of days to retain queue messages1–30 |
visibility_timeout_default | integer | null | Optional | Default visibility timeout in seconds0–43200 |
enable_priority | boolean | null | Optional | Whether priority-based delivery is enabled |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
4. End-to-end example
A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.
A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.
#!/usr/bin/env python3
"""Infrai · queue — runnable real-app example (single file, zero deps).
Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request
KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..." # <- your key
BASE = "https://api.infrai.cc"
# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
req = request.Request(
BASE + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json"})
try:
with request.urlopen(req, timeout=60) as r:
return json.loads(r.read())
except error.HTTPError as e:
return json.loads(e.read())
def show(label, resp):
print(f"\n== {label} ==")
print(json.dumps(resp, indent=2, ensure_ascii=False))
return resp
# 1) queue.create — POST /v1/queue/create · Create a message queue (standard or FIFO, with optional dead-letter queue).
r1 = show("queue.create", infrai("POST", "/v1/queue/create", {"name":"jobs"}))
# 2) queue.publish — POST /v1/queue/publish · Publish a single message to a queue (idempotent).
r2 = show("queue.publish", infrai("POST", "/v1/queue/publish", {"queue":"jobs","payload":{"hello":"world"}}))
# 3) queue.consume — POST /v1/queue/consume · Pull a batch of messages from a queue for processing.
r3 = show("queue.consume", infrai("POST", "/v1/queue/consume", {"queue":"jobs","max_messages":1}))
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at https://infrai.cc/login for a
# project key + $2 free credit (email sign-in starts at $0). On 402
# INSUFFICIENT_CREDIT, add funds at https://infrai.cc/billing (or POST
# /v1/account/topup and open the returned checkout_url).
export INFRAI_API_KEY="ifr_..." # from https://infrai.cc/login
# 2) queue.publish
curl -X POST https://api.infrai.cc/v1/queue/publish \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "orders", "payload": {"order_id": "o_123"}, "priority": 5}'
# 3) queue.create
curl -X POST https://api.infrai.cc/v1/queue/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "example"}'
# 4) queue.get
curl -X GET https://api.infrai.cc/v1/queue/get/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 5) queue.list
curl -X GET https://api.infrai.cc/v1/queue/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 6) queue.update
curl -X PATCH https://api.infrai.cc/v1/queue/update/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# 7) queue.delete
curl -X DELETE https://api.infrai.cc/v1/queue/delete/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 8) queue.purge
curl -X POST https://api.infrai.cc/v1/queue/purge/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"queue": "sample"}'
# 9) queue.stats
curl -X GET https://api.infrai.cc/v1/queue/stats/QUEUE \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 1) Auth: every call is a raw HTTPS request carrying only your project key.
# No SDK to install — just the `requests` library.
import os, requests
BASE = "https://api.infrai.cc"
HEADERS = {
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Content-Type": "application/json",
}
# 2) queue.publish
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/publish",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'orders', 'payload': {'order_id': 'o_123'}, 'priority': 5},
)
resp.raise_for_status()
print(resp.json())
# 3) queue.create
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/create",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'name': 'example'},
)
resp.raise_for_status()
print(resp.json())
# 4) queue.get
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/queue/get/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())
# 5) queue.list
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/queue/list",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())
# 6) queue.update
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.patch(
"https://api.infrai.cc/v1/queue/update/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={},
)
resp.raise_for_status()
print(resp.json())
# 7) queue.delete
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/queue/delete/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())
# 8) queue.purge
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/queue/purge/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'queue': 'sample'},
)
resp.raise_for_status()
print(resp.json())
# 9) queue.stats
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/queue/stats/QUEUE",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch().
const BASE = "https://api.infrai.cc";
const HEADERS = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) queue.publish
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/publish",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "orders", "payload": {"order_id": "o_123"}, "priority": 5}),
},
);
console.log(await resp.json());
// 3) queue.create
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"name": "example"}),
},
);
console.log(await resp.json());
// 4) queue.get
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/get/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 5) queue.list
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 6) queue.update
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/update/QUEUE",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
console.log(await resp.json());
// 7) queue.delete
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/delete/QUEUE",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 8) queue.purge
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/purge/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
console.log(await resp.json());
// 9) queue.stats
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/stats/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch(), typed.
const BASE = "https://api.infrai.cc";
const HEADERS: Record<string, string> = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) queue.publish
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/publish",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "orders", "payload": {"order_id": "o_123"}, "priority": 5}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 3) queue.create
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"name": "example"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 4) queue.get
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/get/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 5) queue.list
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 6) queue.update
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/update/QUEUE",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 7) queue.delete
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/delete/QUEUE",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 8) queue.purge
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/purge/QUEUE",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"queue": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 9) queue.stats
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/queue/stats/QUEUE",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);