Getting Started¶
From sign-up to your first API call in five steps.
1. Create an Account¶
Sign up at app.code2api.io. You'll receive an email with a one-time verification code — no password required.
Once verified, your tenant is provisioned and you'll be issued:
- A dedicated gateway at
https://{your-id}.code2api.io - An agent token for connecting your machines
- An admin API key for the VS Code extension
- A user API key for authenticating API calls
Keep these safe — you can rotate any of them at any time from the portal.
2. Install the VS Code Extension¶
Open VS Code, go to the Extensions panel (Ctrl+Shift+X / Cmd+Shift+X), search for Code2Api, and click Install.
Once installed, click the Code2Api icon in the Activity Bar and run Connect.... Enter:
- Your gateway URL —
https://{your-id}.code2api.io - Your admin API key
The extension connects and shows your relay in the sidebar tree.
3. Connect a Worker Agent¶
Install the Code2Api agent on any Windows or Linux machine you want to execute scripts on. The agent connects outbound only over HTTPS (443) — no inbound ports or firewall changes are needed.
Check with your administrator or the portal for the current agent installer/download — Windows ships as an MSI, Linux as an install script — and pass your agent token when prompted during setup.
Once running, the agent registers automatically and appears as available in your gateway. Connect as many machines as you like — they're grouped by platform (Windows / Linux) automatically.
4. Define and Publish an Endpoint¶
In the VS Code extension sidebar, right-click your relay and select Add Project. Give it a name — for example operations.
Right-click the project and select Add Path. Configure the path:
- Path ID — a short identifier, e.g.
hello - Agent — Windows or Linux, matching your connected machine
- Authentication — select API Key to require the user API key on calls
Right-click the path and select Set Do to open its script in a temporary file. Write your script — for example a simple Bash script on Linux:
Save the file (Ctrl+S / Cmd+S) to publish the endpoint. A confirmation appears in the sidebar and the path is immediately live on your gateway.
If your path uses no authentication, add a Set Check script too — it runs before the "do" script as a validation gate; the call is rejected if it exits non-zero. Paths using API Key or Token authentication skip the check script entirely, since the platform already validates the caller.
5. Make Your First API Call¶
Right-click the path in the sidebar and select Copy as cURL. The extension generates a ready-to-run command with your gateway URL and API key pre-filled.
Or call it directly:
POST https://{your-id}.code2api.io/api-key/operations/hello
X-API-Key: YOUR_USER_API_KEY
Content-Type: application/json
{ "params": {} }
The gateway authenticates the request, dispatches it to your connected agent, executes the script, and returns the output as the HTTP response — synchronously, like any other API call.
All requests require a
paramsobject in the body, even if your endpoint has no parameters defined. Pass{ "params": {} }when there are none.
Next Steps¶
Now that your first endpoint is working, you can:
- Add parameters to your path and read them in your script
- Write a check script for custom request validation when not using API key or token auth
- Use token authentication to accept signed bearer tokens from your own identity provider
- Enable the Swagger UI from the portal to get auto-generated API documentation
- Set up a custom domain so your API is served from
api.yourcompany.com