-
Notifications
You must be signed in to change notification settings - Fork 77
Managed wallet API
Anil Murty edited this page Apr 11, 2025
·
6 revisions
This guide demonstrates how to create and manage a deployment with a lease using the Akash Console API and an API key.
- An API key from the Akash Console
- Node.js installed on your system (it can be any other language)

The full example script can be found here
The script executes the following steps in sequence:
-
Certificate Creation
- Creates a new certificate for secure communication
- Returns
certPemandencryptedKeyfor use in lease creation
-
Deployment Creation
- Creates a deployment using the provided SDL file
- Uses a default deposit of 5$
- Returns deployment sequence ID (
dseq) and manifest
-
Bid Collection
- Waits for and collects bids from providers
- Polls the API every 3 seconds (max 10 attempts)
- Selects the first available bid
-
Lease Creation
- Creates a lease using the selected bid
- Sends the deployment manifest
- Includes certificate information for secure communication
-
Deposit Deployment
- Deposit in the deployment of 0.5$
-
Deployment Closure
- Closes the deployment after lease creation
You can do this flow with any language, however in this example we'll be using nodejs.
All requests require the following headers:
{
"Content-Type": "application/json",
"x-api-key": "your-api-key-here"
}const api = axios.create({
baseURL: "https://console-api.akash.network",
headers: {
"Content-Type": "application/json"
}
});// Response Type
interface CertificateResponse {
data: {
data: {
certPem: string; // Certificate in PEM format
encryptedKey: string; // Encrypted private key
}
}
}
// API Call
const certResponse = await api.post<CertificateResponse>(
"/v1/certificates",
{}, // Empty request body
{
headers: {
"x-api-key": apiKey
}
}
);// Request Type
interface CreateDeploymentRequest {
data: {
sdl: string; // SDL file content
deposit: number; // Amount in dollars with minimum 5$
}
}
// Response Type
interface CreateDeploymentResponse {
data: {
data: {
dseq: string; // Deployment sequence ID
manifest: string; // Deployment manifest
}
}
}
// API Call
const deployResponse = await api.post<CreateDeploymentResponse>(
"/v1/deployments",
{
data: {
sdl: yml,
deposit: 5
}
} as CreateDeploymentRequest,
{
headers: {
"x-api-key": apiKey
}
}
);// Response Type
interface BidID {
owner: string;
dseq: string;
gseq: number;
oseq: number;
provider: string;
}
interface Bid {
bid_id: BidID;
state: string;
price: {
denom: string;
amount: string;
};
created_at: string;
}
interface BidsResponse {
data: {
data: {
bid: Bid;
}[];
}
}
// API Call
async function waitForBids(dseq: string, apiKey: string, maxAttempts = 10): Promise<Bid[]> {
for (let i = 0; i < maxAttempts; i++) {
const response = await api.get<BidsResponse>(`/v1/bids?dseq=${dseq}`, {
headers: {
"x-api-key": apiKey
}
});
if (response.data?.data?.length > 0) {
return response.data.data;
}
await new Promise(resolve => setTimeout(resolve, 3000));
}
throw new Error("No bids received after maximum attempts");
}// Request Type
interface CreateLeaseRequest {
manifest: string;
certificate: {
certPem: string;
keyPem: string;
};
leases: {
dseq: string;
gseq: number;
oseq: number;
provider: string;
}[];
}
interface CreateLeaseResponse {
data: {
deployment: {
deployment_id: {
owner: string;
dseq: string;
};
state: string;
version: string;
created_at: string;
};
leases: {
lease_id: {
owner: string;
dseq: string;
gseq: number;
oseq: number;
provider: string;
};
state: string;
price: {
denom: string;
amount: string;
};
created_at: string;
closed_on: string;
}[];
escrow_account: {
id: {
scope: string;
xid: string;
};
owner: string;
state: string;
balance: {
denom: string;
amount: string;
};
transferred: {
denom: string;
amount: string;
};
settled_at: string;
depositor: string;
funds: {
denom: string;
amount: string;
};
};
}
}
// API Call
const leaseResponse = await api.post<CreateLeaseResponse>(
"/v1/leases",
{
manifest,
certificate: {
certPem,
keyPem: encryptedKey
},
leases: [
{
dseq,
gseq: firstBid.bid.bid_id.gseq,
oseq: firstBid.bid.bid_id.oseq,
provider: firstBid.bid.bid_id.provider
}
]
} as CreateLeaseRequest,
{
headers: {
"x-api-key": apiKey
}
}
);// Request Type
interface DepositDeploymentRequest {
data: {
deposit: number;
dseq: string;
}
}
// Response Type
interface DepositDeploymentResponse {
data: CreateLeaseResponse
}
// API Call
const depositResponse = await api.delete<DepositDeploymentResponse>(
`/v1/deposit-deployment`,
{
data: {
dseq,
deposit: 0.5
}
} as DepositDeploymentRequest,
{
headers: {
"x-api-key": apiKey
}
}
);// Response Type
interface CloseDeploymentResponse {
data: {
data: {
status: string;
message: string;
}
}
}
// API Call
const closeResponse = await api.delete<CloseDeploymentResponse>(
`/v1/deployments/${dseq}`,
{
headers: {
"x-api-key": apiKey
}
}
);