https-outcalls

Make HTTPS requests from Internet Computer canisters to external web APIs.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/phukrit7171/Relationship-Smart-Contract-ICP --skill https-outcalls-phukrit7171
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: https-outcalls
Source: https://github.com/phukrit7171/Relationship-Smart-Contract-ICP/tree/main/.agents/skills/https-outcalls
Command: npx skills add https://github.com/phukrit7171/Relationship-Smart-Contract-ICP --skill https-outcalls-phukrit7171

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Canisters on the Internet Computer run on replicated subnets, so calling external web APIs directly fails consensus when responses differ between nodes. This Skill shows how to make HTTPS outcalls with transform functions, correct cycle attachment, and response size limits so canisters can reliably fetch or send data to external services. ## Core Features & Use Cases - Consensus-safe HTTP requests: Transform functions strip non-deterministic headers and fields so all replicas agree on the response. - Cycle cost management: Automatic cycle calculation via Call.httpRequest (Motoko) or ic_cdk::management_canister::http_request (Rust), with guidance on max_response_bytes to avoid overpaying. - GET and POST patterns in Motoko and Rust: Complete working examples including JSON parsing, idempotency keys, and error handling. - Use Case: Build a canister that fetches the ICP/USD price from CoinGecko, or posts JSON data to an external webhook with an idempotency key to handle duplicate replica requests. ## Quick Start Ask the AI to write a Rust or Motoko canister function that fetches JSON data from an external HTTPS API using a transform function for consensus.

Frequently Asked Questions about https-outcalls

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make an HTTP request from an Internet Computer canister?

Call the management canister's http_request method with a URL, method, headers, and a transform function. In Motoko use Call.httpRequest from the ic mops package; in Rust use ic_cdk::management_canister::http_request, both of which attach the required cycles automatically.

Why do HTTPS outcalls need a transform function?

All replicas on the subnet execute the same request, but raw responses differ in headers, timestamps, and JSON field ordering. The transform function strips non-deterministic data so every replica sees an identical response and consensus can be reached.

How much do HTTPS outcalls cost in cycles?

Cost is computed by the ic0.cost_http_request system API from request size and max_response_bytes. On a 13-node subnet the base is about 49 million cycles plus per-byte charges; omitting max_response_bytes defaults to 2MB and costs roughly 21.5 billion cycles.

Can canisters call localhost or private IP addresses?

No. HTTPS outcalls only reach public internet endpoints with valid TLS certificates. Localhost, 10.x.x.x, 192.168.x.x, and other private ranges are blocked, and plain HTTP URLs are rejected.

Why does my outcall fail with no consensus could be reached?

The transform function is not making responses identical across replicas. Strip all headers, normalize JSON field ordering by parsing and re-serializing, and remove timestamps or per-replica fields like origin IPs from the body.

What is the maximum response size for HTTPS outcalls?

The maximum response body is 2MB (2,097,152 bytes). Set max_response_bytes to a realistic upper bound for your API, since cycles are charged against this limit rather than the actual response size.