Endpoints

URL Naming

Every Diagram projects is constituted from a number of endpoints. Each endpoint have a different name which is set to Untitled by default. The final URL of the endpoint is generated based on the endpoint name and the project unique id. For example in https://www.ondiagram.com/api/call/project-id/endpoint-name, the project unique id is "project-id" and the endpoint name is "endpoint-name".

Endpoints with names that are separated with slashes (ie. "/") are shown in folder in dashboard screen. For example "auth/login" endpoint is saved as "login" in a folder called "auth".

Request Node

Every endpoint can have one of the four basic HTTP verbs ie. GET, POST, PUT, DELETE. By default, every endpoint that is not created from a template is set to GET. Template endpoints have different HTTP verbs according to their use. After the endpoint is created the request type can change in the request node settings. This node has a Headers and a Params output ports. The headers output contains the an object with the request headers such as hostname and user agent and the params output the query params of the request. For example, for the endpoint /api/call/project/get?name=test its request params are an object with a "name" property set to "test". Aside from GET requests, other endpoints also have a Body output that contains an object with the HTTP body data. There's an option in request settings to get HTTP body as raw which returns the HTTP body as a string. A common instance that this is useful is with Stripe webhooks that require the raw HTTP body to verify that the request came from Stripe servers.

The HTTP verb of the endpoint that is edited is shown in the top left corner right next to the endpoint URL.

Types of Nodes

Every newly created endpoint comes with a Request node. From there, nodes can be added to the canvas from the left side panel. Every node has different functionality and different input and output ports. A single click on the node opens the settings panel and a long click on the node shows the trash bin icon. To delete the node simply drag it over the trash bin and release.

Response Node

in contrast with the request node, one endpoint can have multiple response nodes. For instance, it's common to have different responses for different conditions in the endpoint. For example, a login endpoint would normally return a status code of 200 and a message saying something like "You have login successfully" when the user credentials are correct and a status code of 401 with a message of "Your email or password is invalid" if the credentials do not match the records in the database.

Diagram supports the following HTTP status codes:

  • 200 OK

  • 301 Moved Permanently

  • 302 Found

  • 304 Not Modified

  • 307 Temporary Redirect

  • 400 Bad Request

  • 401 Unauthorised

  • 403 Forbidden

  • 404 Not Found

  • 500 Internal Server Error

  • 503 Service Unavailable

For any response node the HTTP body can be passed from the node input or can be statically set if the "Static" option is set to true. As of now, static response can only be objects while responses from inputs can be strings, objects or arrays.

A response node is not required for a node to run but executing the API without one would return Internal Server Error and an error code of 500.

Last updated

Was this helpful?