1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

site

doc

blog

success stories

Edge Functions

Edit on GitHub

The API of Edge Functions allows you to check, remove or update your existing settings, as well as creating new ones.

  1. Retrieving a list of Edge Functions
  2. Retrieving details of an Edge Function
  3. Deleting an Edge Function
  4. Creating a new Edge Function
  5. Overwriting an Edge Function
  6. Updating the fields of an Edge Function
  7. Support Documentation

1. Retrieving a list of Edge Functions

It returns a list of Edge Fucntions.

GET /edge_functions

Required permission: View Edge Functions

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
Settings code (string): mandatory field where the Edge Function code will be inserted.


name (string): mandatory field that defines a name for the Edge Function.

language (string): mandatory field that defines what language will be used in the Edge Function.


initiator_type (string): mandatory field that defines which Edge Function will be used.


active (boolean): mandatory field intended to show wheter the Edge Function is active or not.


json_args (json scheme): optional field intended to declare arguments without updating the code.
body json

Request Example

GET /edge_functions
Accept: application/json; version=3
Authorization: token a5abb58290608193a5771a4b3494821a177b8a3c

Response Example

{
    "count": 6,
    "total_pages": 1,
    "schema_version": 3,
    "links": {
        "previous": null,
        "next": null
    },
 
            },
            "function_to_run": "create_body",
            "initiator_type": "edge_application",
            "active": true,
            "last_editor": "Azion",
            "modified": "2021-01-18T16:38:41.996139Z",
            "reference_count": 1
        },
        {
            "id": 3878,
            "name": "Fauna Database",
            "language": "javascript",
        
            "json_args": {},
            "function_to_run": "handleRequest",
            "initiator_type": "edge_application",
            "active": true,
            "last_editor": "api@azion.com.br",
            "modified": "2021-06-17T18:40:29.514576Z",
            "reference_count": 0
        },
        {
            "id": 4071,
            "name": "js-test",
            "language": "javascript",
            "code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
            "json_args": {
                "key": "value"
            },
            "function_to_run": "js-test",
            "initiator_type": "edge_application",
            "active": true,
            "last_editor": "api@azion.com.br",
            "modified": "2021-09-17T17:57:36.265615Z",
            "reference_count": 0
        },
        {
            "id": 4079,
            "name": "Function Test API",
            "language": "javascript",
            "code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
            "json_args": {
                "key": "value"
            },
            "function_to_run": "js-test",
            "initiator_type": "edge_application",
            "active": true,
            "last_editor": "api@azion.com.br",
            "modified": "2021-09-30T19:43:06.326579Z",
            "reference_count": 0
        }

##

2. Retrieving the details of an Edge Function

It returns details of an Edge Function. The information returned by this command refers to the main settings of a function.

GET /edge_functions/:id

Required permission: View Edge Functions

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
:id
*required
The id of the edge function you plan to query. path number
Settings code (string): mandatory field where the Edge Function code will be inserted.


name (string): mandatory field that defines a name for the Edge Function.

language (string): mandatory field that defines what language will be used in the Edge Function.


initiator_type (string): mandatory field that defines which Edge Function will be used.


active (boolean): mandatory field intended to show wheter the Edge Function is active or not.


json_args (json scheme): optional field intended to declare arguments without updating the code.
body json

Request Example

GET /edge_functions/1528990724
Accept: application/json; version=3
Authorization: token a5abb58290608193a5771a4b3494821a177b8a3c

Response Example

{
    "results": {
        "code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
        "name": "js-test",
        "language": "javascript",
        "modified": "2021-09-14T14:22:16.234852Z",
        "initiator_type": "edge_application",
        "reference_count": 0,
        "function_to_run": "js-test",
        "active": true,
        "last_editor": "api@azion.com.br",
        "id": 4067,
        "json_args": {"key": "value"}
    },
    "schema_version": 3
}

3. Deleting an Edge Function

It removes an Edge Function. This operation is final. It means there is no way to roll back the information after it has been confirmed by the user.

All information associated with this function will also be removed.

The API does not require confirmation in order to run this instruction.

DELETE /edge_functions/:id

Required permission: Edit Edge Functions

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
:id
*required
The id of the edge function you plan to delete. path number

Request Example

DELETE /edge_functions/1548170897
Accept: application/json; version=3
Authorization: token a5abb58290608193a5771a4b3494821a177b8a3c

Response Example

HTTP/2 204

4. Creating a new Edge Function

It enables you to create a new Edge Function.

POST /edge_functions

Required permission: Edit Edge Functions

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
Content-Type
*required
The type of coding used in the Body (application/json).

Example:
Content-Type: application/json
header string
Settings code (string): mandatory field where the Edge Function code will be inserted.


name (string): mandatory field that defines a name for the Edge Function.

language (string): mandatory field that defines what language will be used in the Edge Function.


initiator_type (string): mandatory field that defines which Edge Function will be used.


active (boolean): mandatory field intended to show wheter the Edge Function is active or not.


json_args (json scheme): optional field intended to declare arguments without updating the code.
body json

Request Example

POST /edge_functions
Accept: application/json; version=3
Authorization: token a5abb58290608193a5771a4b3494821a177b8a3c
Content-Type: application/json

{
	"name": "Function Test API",
	"function_to_run": "js-test",
	"initiator_type": "edge_application",
	"code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
	"language": "javascript",
	"json_args": {"key": "value"},
    "active": true
}

Response Example

"results": {
        "code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
        "name": "Function Test API",
        "language": "javascript",
        "modified": "2021-09-14T15:22:41.773372Z",
        "initiator_type": "edge_application",
        "function_to_run": "js-test",
        "active": true,
        "last_editor": "api@azion.com.br",
        "id": 4068,
        "json_args": {"key": "value"}
    },
    "schema_version": 3
}

5. Overwriting an Edge Function

It overwrites all the fields of an Edge Function, retaining the id.

If you only want to update some fields, without changing the values of the rest, consider using the PATCH method, instead of PUT.

PUT /edge_functions/:id

Required permission: Edit Edge Functions

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
Content-Type
*required
The type of coding used in the Body (application/json).

Example:
Content-Type: application/json
header string
:id
*required
The Id of the Edge Function to be overwritten. path number
Settings code (string): mandatory field where the Edge Function code will be inserted.


name (string): mandatory field that defines a name for the Edge Function.

language (string): mandatory field that defines what language will be used in the Edge Function.


initiator_type (string): mandatory field that defines which Edge Function will be used.


active (boolean): mandatory field intended to show wheter the Edge Function is active or not.


json_args (json scheme): optional field intended to declare arguments without updating the code.
body json

Request Example

PUT /edge_functions/1555421177
Accept: application/json; version=3
Authorization: token a5abb58290608193a5771a4b3494821a177b8a3c
Content-Type: application/json

{
	"name": "js-test-2",
	"code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
	"json_args": {"key": "value"}
    "active": true
}

Response Example

{
    "results": {
        "code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
        "name": "js-test-2",
        "language": "javascript",
        "modified": "2021-09-14T14:41:36.542092Z",
        "initiator_type": "edge_application",
        "function_to_run": "js-test",
        "active": true,
        "last_editor": "api@azion.com.br",
        "id": "4067",
        "json_args": {"key": "value"}
    },
    "schema_version": 3
}

6. Updating the fields of an Edge Function

It updates one or more fields of a function, retaining the value of those fields not included.

PATCH /edge_functions/:id

Required permission: Edit Edge Functions

Parameter Description Type Type of Data
Authorization
*required
Authentication through the Token, previously created through the endpoint of Token Creation. header string
Accept
*required
Details about the type of return and version. header string;
application/json;version=3
Content-Type
*required
The type of coding used in the Body (application/json).

Example:
Content-Type: application/json
header string
:id
*required
The Id of the Edge Function to be updated. path number
Settings code (string): mandatory field where the Edge Function code will be inserted.


name (string): mandatory field that defines a name for the Edge Function.

language (string): mandatory field that defines what language will be used in the Edge Function.


initiator_type (string): mandatory field that defines which Edge Function will be used.


active (boolean): mandatory field intended to show wheter the Edge Function is active or not.


json_args (json scheme): optional field intended to declare arguments without updating the code.
body json

Request Example

PATCH /edge_functions/4068
Accept: application/json; version=3
Authorization: token 8a8ca02e6d2768332512aab8656ffd0f51c08bc2
Content-Type: application/json

{
"name": "js-test-2",
"code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
"json_args": {"key": "value"},
"active": true
}

Response Example

{
"results": {
    "code": "{\r\n    async function handleRequest(request) {\r\n        return new Response(\"Hello world in a new response\");\r\n    }\r\n\r\n    addEventListener(\"fetch\", (event) => {\r\n        event.respondWith(handleRequest(event.request));\r\n    });\r\n}",
    "name": "js-test-2",
    "language": "javascript",
    "modified": "2021-09-17T17:59:34.474349Z",
    "initiator_type": "edge_application",
    "function_to_run": "js-test",
    "active": true,
    "last_editor": "api@azion.com.br",
    "id": 4068,
    "json_args": {"key": "value"}
},
"schema_version": 3
}

7. Support Documentation


Didn’t find what you were looking for? Open a ticket.