The SGS API
The SGS API lets you tag the nodes on your SGS server, then route requests to nodes that carry a given tag. A typical use is to test each node against a site, tag the nodes that pass, and send that site’s traffic only to those nodes. You develop, run, and maintain any such connectivity tests yourself.The SGS API is in limited release and is only available on some SGS servers. Contact your account manager to enable
it.
7443 of your SGS server (https://{sgsName}.salad.com:7443). Tag-based routing is available
for HTTP CONNECT requests.
Routing requests to tagged nodes
Requesting a tag
Add theX-Sgs-Tag proxy header to your HTTP CONNECT request:
internal-site-a and Internal-Site-A are different tags.
How node selection works
For each request, SGS checks the following in order and uses the first one that matches:X-Sgs-Machine-Idheader. The request is pinned to that exact node (see Targeting a specific node).X-Sgs-Tagheader. SGS chooses from the nodes that are currently connected and have the tag.- Normal routing. If no connected node has the tag, SGS routes the request normally.
Targeting a specific node
TheX-Sgs-Machine-Id proxy header sends a request to a specific node. This is mainly useful for testing nodes one at a
time.
- If the node is not currently connected to your SGS server (it is offline, or it has been quarantined), the request
fails immediately with
503 Service Unavailable. SGS does not fall back to another node. - If the node accepts the request but cannot reach the destination, SGS may retry the request on a different node.
503 on a pinned request usually just means the node is offline right now. It does not mean the node failed your
test.
Authentication
Every API request requires your Salad-provided JWT:401 Unauthorized. Your JWT was shared with your team
during initial integration. If you need one, contact your account manager.
Endpoints
List all nodes
Example response
machine_id: the node’s Salad machine ID.tags: the node’s tags and their values. A node with no tags has an empty object.updated_at: a UTC timestamp.
Retrieve a node
nodes list.
Retrieve a node’s tags
Example response
Update a node’s tags
- Any value other than
0adds the tag, or updates it if the node already has it. - A value of
0removes the tag.
0 to 1. Today, routing only checks whether a node has a tag, so 0.5 and 1 behave the same.
Values between 0 and 1 are reserved for future weighted load balancing.
Example request
internal-site-a and internal-site-c, and removes internal-site-b.
Example response
The response contains the node’s full set of tags after the update:Remove all tags
Errors
Errors return a JSON body with the HTTP status code and its name:Common workflows
Qualifying nodes for a new site
-
List all nodes and get their machine IDs:
-
For each machine ID, test the node against the target site by pinning the request to it. Don’t add an
X-Sgs-Tagheader while testing.If the proxy returns503, the node is usually offline. Skip it and leave its tags as they are. -
Tag the nodes that passed, using a unique tag name such as
internal-target-site. Set the tag to0on nodes that failed: -
Check that the tags were updated:
-
Route the site’s traffic to the tagged nodes by adding the proxy header
X-Sgs-Tag: internal-target-siteto your requests. - Nodes connect and disconnect over time, and their ability to reach a site can change. Repeat steps 1–4 regularly, at least every 2–3 hours. Nodes that are offline during a pass keep their existing tags, and SGS only routes to tagged nodes that are connected.