Sure API
by @ashanzzz
Use the we-promise/sure REST API with X-Api-Key auth. Covers accounts, transactions, categories, tags, merchants, imports, holdings, trades, valuations, chat...
clawhub install sure-apiπ About This Skill
name: sure-api description: Use the we-promise/sure REST API with X-Api-Key auth. Covers accounts, transactions, categories, tags, merchants, imports, holdings, trades, valuations, chats, official docs URLs, self-update workflow from upstream OpenAPI, and ClawHub publish readiness.
Sure API
Use this skill when the user asks to:
Official source-of-truth URLs
These are the URLs the agent should trust first when updating or validating this skill:
https://github.com/we-promise/surehttps://github.com/we-promise/sure/tree/main/docs/apihttps://github.com/we-promise/sure/blob/main/docs/api/openapi.yamlhttps://raw.githubusercontent.com/we-promise/sure/main/docs/api/openapi.yamlIf behavior and local scripts disagree, re-check the upstream OpenAPI first.
Local config
Read secrets from secure env only:
SURE_BASE_URLSURE_API_KEYSingle source of truth: secure/api-fillin.env
Never paste the API key into chat or into non-secure files.
Auth
Default auth header:
X-Api-Key: Note: the current upstream OpenAPI snapshot also shows Authorization header notes on some valuation endpoints. Treat upstream OpenAPI as authoritative if those endpoints behave differently in practice.
Skill layout
skills/sure-api/
βββ SKILL.md
βββ references/
β βββ openapi.yaml
β βββ api_endpoints_summary.md
βββ scripts/
βββ sure_api_request.sh
βββ sure_api_smoke.sh
βββ sure_api_cli.js
βββ sure_openapi_update.sh
βββ sure_openapi_summarize.js
βββ sure_api_acceptance.sh
Capability model
This skill has two layers:
Layer 1: high-level wrapped commands
Use these first for common operations.Implemented in scripts/sure_api_cli.js:
accounts:listcategories:listtags:listtags:createtags:updatetags:deletemerchants:listtransactions:listtransactions:gettransactions:createtransactions:updatetransactions:deleteimports:listholdings:listtrades:listLayer 2: raw official endpoint access
For any official endpoint not yet wrapped by the high-level CLI, use:bash skills/sure-api/scripts/sure_api_request.sh [curl args...] This means the skill can still operate against official endpoints such as:
references/openapi.yamlQuick start
Smoke test
bash skills/sure-api/scripts/sure_api_smoke.sh
Common wrapped commands
node skills/sure-api/scripts/sure_api_cli.js accounts:list
node skills/sure-api/scripts/sure_api_cli.js categories:list --classification expense
node skills/sure-api/scripts/sure_api_cli.js tags:list
node skills/sure-api/scripts/sure_api_cli.js merchants:list
node skills/sure-api/scripts/sure_api_cli.js transactions:list --start_date 2026-03-01 --end_date 2026-03-31 --type expense
node skills/sure-api/scripts/sure_api_cli.js holdings:list --account_id
node skills/sure-api/scripts/sure_api_cli.js trades:list --account_id --start_date 2026-03-01 --end_date 2026-03-31
Safe write pattern
Always prefer: 1. read current state 2. dry-run if the wrapped command supports it 3. send the real write only with explicit confirmation flags
Example:
node skills/sure-api/scripts/sure_api_cli.js transactions:create \
--account_id \
--date 2026-03-01 \
--amount 12.34 \
--name "ει₯" \
--nature expense \
--dry-runnode skills/sure-api/scripts/sure_api_cli.js transactions:create \
--account_id \
--date 2026-03-01 \
--amount 12.34 \
--name "ει₯" \
--nature expense \
--yes
Raw endpoint examples for official API coverage
Retrieve a merchant by id
bash skills/sure-api/scripts/sure_api_request.sh GET /api/v1/merchants/
Retrieve a holding by id
bash skills/sure-api/scripts/sure_api_request.sh GET /api/v1/holdings/
Retrieve an import by id
bash skills/sure-api/scripts/sure_api_request.sh GET /api/v1/imports/
Create an import from raw CSV content
bash skills/sure-api/scripts/sure_api_request.sh POST /api/v1/imports \
-H 'Content-Type: application/json' \
-d '{
"raw_file_content": "date,amount,name\n2026-03-01,12.34,ει₯",
"type": "TransactionImport",
"account_id": "",
"publish": "true"
}'
Create a trade
bash skills/sure-api/scripts/sure_api_request.sh POST /api/v1/trades \
-H 'Content-Type: application/json' \
-d '{
"trade": {
"account_id": "",
"date": "2026-03-01",
"qty": 10,
"price": 12.5,
"type": "buy",
"ticker": "AAPL"
}
}'
Create a valuation
bash skills/sure-api/scripts/sure_api_request.sh POST /api/v1/valuations \
-H 'Content-Type: application/json' \
-d '{
"valuation": {
"account_id": "",
"amount": 10000,
"date": "2026-03-01",
"notes": "Month-end valuation"
}
}'
Create a chat and send a message
bash skills/sure-api/scripts/sure_api_request.sh POST /api/v1/chats \
-H 'Content-Type: application/json' \
-d '{"title":"Monthly review","message":"Summarize March spending"}'bash skills/sure-api/scripts/sure_api_request.sh POST /api/v1/chats//messages \
-H 'Content-Type: application/json' \
-d '{"content":"Show biggest merchant changes"}'
Pagination and filtering
Most list endpoints return a resource list plus a pagination block. Typical filters in the official API include:
pageper_pageFor exact parameters, read references/openapi.yaml.
Error handling
401 / 403 β auth missing, invalid, or insufficient feature scope404 β wrong path or object not found422 β validation error; inspect request body against references/openapi.yaml429 / 5xx β retry with backoff up to 3 times if the action is idempotentSelf-update this skill
This skill is designed to be self-maintainable.
Fast refresh from official API
bash skills/sure-api/scripts/sure_openapi_update.sh
What it does:
1. downloads the latest official OpenAPI from the Sure GitHub repo
2. overwrites references/openapi.yaml
3. regenerates references/api_endpoints_summary.md
After updating OpenAPI
Do this in order:
1. re-read references/api_endpoints_summary.md
2. compare new endpoints/params with current sure_api_cli.js
3. extend high-level wrappers only for endpoints that are common, stable, and worth scripting
4. keep less-common endpoints accessible via sure_api_request.sh
5. run acceptance checks
When to read references
Read references/openapi.yaml when you need:
Read references/api_endpoints_summary.md when you need:
ClawHub publish readiness
Before publishing or bumping a version, run:
bash skills/sure-api/scripts/sure_api_acceptance.sh
Optional live API validation:
bash skills/sure-api/scripts/sure_api_acceptance.sh --with-live-api
The acceptance script checks:
SKILL.md frontmatter is valid enough for publishingClawHub publish commands
First confirm login:
clawhub whoami
Initial publish example:
cd /root/.openclaw/workspace
clawhub publish ./skills/sure-api \
--slug sure-api \
--name "Sure API" \
--version 1.0.0 \
--changelog "Initial public release." \
--tags latest
Update publish example:
cd /root/.openclaw/workspace
clawhub publish ./skills/sure-api \
--slug sure-api \
--name "Sure API" \
--version 1.0.1 \
--changelog "Refresh official OpenAPI, tighten docs, and improve publish readiness." \
--tags latest
Notes for future maintenance
SKILL.md concise; put exact API detail in references/.sure_api_cli.js; leave long-tail official endpoints to the raw request wrapper.π‘ Examples
Smoke test
bash skills/sure-api/scripts/sure_api_smoke.sh
Common wrapped commands
node skills/sure-api/scripts/sure_api_cli.js accounts:list
node skills/sure-api/scripts/sure_api_cli.js categories:list --classification expense
node skills/sure-api/scripts/sure_api_cli.js tags:list
node skills/sure-api/scripts/sure_api_cli.js merchants:list
node skills/sure-api/scripts/sure_api_cli.js transactions:list --start_date 2026-03-01 --end_date 2026-03-31 --type expense
node skills/sure-api/scripts/sure_api_cli.js holdings:list --account_id
node skills/sure-api/scripts/sure_api_cli.js trades:list --account_id --start_date 2026-03-01 --end_date 2026-03-31
Safe write pattern
Always prefer: 1. read current state 2. dry-run if the wrapped command supports it 3. send the real write only with explicit confirmation flags
Example:
node skills/sure-api/scripts/sure_api_cli.js transactions:create \
--account_id \
--date 2026-03-01 \
--amount 12.34 \
--name "ει₯" \
--nature expense \
--dry-runnode skills/sure-api/scripts/sure_api_cli.js transactions:create \
--account_id \
--date 2026-03-01 \
--amount 12.34 \
--name "ει₯" \
--nature expense \
--yes