# API Calls

Codavel's API allows the following remote configuration calls:

A/B Testing Config

Pre-Populate Cache

Purge Cache

Version Blocking

# A/B Testing Config

Codavel's API provides a simple way for you to change the bolina's A/B testing percentage:

curl \
    --request POST \
    --header 'content-type: application/json' \
    --header 'secret: <did_secret>' \
    --data '{"ab_test_percentage": <AB_TEST_PERCENTAGE>}' \
    https://api.cloud.codavel.com/deployment/updateabTesting/<your_deployment_id>
1
2
3
4
5
6

IMPORTANT: The AB_TEST_PERCENTAGE must be a number and must be within the range of 0 to 100, both included.

# Success:

If no errors occur, the response will be 200 OK, telling you that your deployment was updated with the desired ab test percentage.

# Error handling:

If an error occurs when sending the request you will receive an error message, that will help you verify what went wrong with your request.

Some of the more typical error messages, and possible fixes are:

  • # "error": "Not authorized":

The authentication process for your deployment failed. Please make sure that the "secret: <deployment_secret>" header is correct, and that the secret used is for your deployment.

  • # "error": "Bad request":

The request didn't contain ab_test_percentage or it was not a number.

  • # "error": "AB test percentage must be in range of 0 to 100":

The ab_test_percentage was not in range of 0 to 100.

# Pre-Populate Cache

Codavel's CDN architecture can preveniently populate your deployment's cache with some of your highly requested content, significantly reducing your users waiting time.

# Cache data pre-fetching

Codavel's API provides a simple way for you to pre-cache specific content by performing the following curl command:

curl \
    --request POST \
    --header 'content-type: application/json' \
    --header 'secret: <deployment_secret>' \ 
    --data @requestsFile.json \
    https://api.cloud.codavel.com/deployment/prepopulate/<your_deployment_id>
1
2
3
4
5
6

in which requestsFile.json is a json file where you specify the requests whose content will be pre-fetched, using the following syntax:

requestsFile.json:

{
    "urls": [
    {
        "url":"https://www.example-content-url.com",
            "headers": [
            {"header 1":"value 1"},
            {"header 2":"Value 2"},
            ...
            ]
    },
    {
        "url":"http://www.another-example-content-url.com",
        "headers": [
        {"header 1":"value 1"},
        {"header 2":"Value 2"},
        ...
        ]
    },
    ...
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

# Output:

If no errors occur, the received response should look something like this:

"status": "Sucessful request"
1

Important: Any valid request given to this endpoint will overwrite any previous fetched content. If you wish to add or correct any request, make sure you also include any previous requests you would want to maintain in your cache.

# Error handling:

If an error occurs during the pre-populating process you should receive an error message, giving you a bit more insight on what went wrong.

Some of the more typical error messages, and possible fixes are:

  • # "error": "Not authorized":

The authentication process for your deployment failed. Please make sure that the "secret: <deployment_secret>" header is correct, and that the secret used is for your deployment.

  • # "error": "Bad request format":

The parsing process for your pre-populate request failed. Please unsure that your requestsFile.json file is structured as shown above.

  • # "error": "Request list too large - max allowed is 1MB":

Your requestsFile.json size exceeds the maximum allowed.

  • # "error": "Only HTTP and HTTPS protocol are allowed":

Your pre-populate request use other protocols besides HTTP(S).

# Purge Cache

Codavel's CDN architecture allows you to purge previously cached content from your deployment's cache, reducing the amount of space stale content occupies in your cache and forcefully refresh content the next time one of your users demands it.

# Cache data purging

Codavel's API provides a simple way for you to purge specific content by performing the following curl command:

curl \
    --request POST \
    --header 'content-type: application/json' \
    --header 'secret: <deployment_secret>' \ 
    --data @requestsFile.json \
    https://api.cloud.codavel.com/deployment/purge/<your_deployment_id>
1
2
3
4
5
6

in which requestsFile.json is a json file where you specify the content to be purged, using the following syntax:

requestsFile.json:

{
    "contentToPurge":[
        {
            "type":"[BASENAME]",
            "content": "example-image.jpeg"
        },
        {
            "type":"[FILENAME]",
            "content": "example-image"
        },
        {
            "type":"[EXTENSION]",
            "content": "jpeg"
        },
        {
            "type":"[MIMETYPE]",
            "content": "image/jpeg"
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Where each entry in the requestsFile.json is composed of:

  • type tag, specifying the filter for the content to be purged:

    • [ALL] Purges all content from the cache, ignoring the content associated tag:
    "type":"[ALL]",
    "content": ""
    
    1
    2

    Important: content tag is still mandatory.

    • [FULL_URL] Purges content pointed to by the given full url:
    "type":"[FULL_URL]",
    "content": "/content/example-image.jpg"
    
    1
    2
    • [BASENAME] Purges content with the given base name (including file extensions):
    "type":"[BASENAME]",
    "content": "example-image.jpg"
    
    1
    2
    • [FILENAME] Purges content with the given file name (excluding file extensions):
    "type":"[FILENAME]",
    "content": "example-image"
    
    1
    2
    • [EXTENSION] Purges content with the given extension:
    "type":"[EXTENSION]",
    "content": "jpeg"
    
    1
    2
    • [MIMETYPE] Purges content with the given MIME type:
    "type":"[MIMETYPE]",
    "content": "image/jpeg"
    
    1
    2

# Output:

If no errors occur, the received response should look something like this:

"status": "Sucessful request"
1

Important: Codavel's CDN architecture will purge the selected content as soon as possible, as such make sure you specified the correct content to be purged.

# Error handling:

If an error occurs during the purge process you should receive an error message, giving you a bit more insight on what went wrong.

Some of the more typical error messages, and possible fixes are:

  • # "error": "Not authorized":

The authentication process for your deployment failed. Please make sure that the "secret: <deployment_secret>" header is correct, and that the secret used is for your deployment.

  • # "error": "Bad request format":

The parsing process for your purge request failed. Please unsure that your requestsFile.json file is structured as shown above.

  • # "error": "Request list too large - max allowed is 1MB":

Your requestsFile.json size exceeds the maximum allowed.

# Version Blocking

Codavel's CDN architecture is able to block specific versions of our SDK for a given deployment ID. This way, if you want your app to stop using our SDK you just need to make a call to this endpoint.

# Blocking one or more versions

Codavel's API provides a simple way for you to block one or more versions of our SDK by performing the following curl command:

curl \
    --request POST \
    --header 'content-type: application/json' \
    --header 'secret: <deployment_secret>' \
    --data @versions.json \
    https://api.cloud.codavel.com/versions/block/<deployment_id>
1
2
3
4
5
6

in which versions.json is a json file where you specify the versions to be blocked, using the following syntax:

versions.json:

{
    "versions": [
        "a.b.c",
        "a.b.e"
    ]
}
1
2
3
4
5
6

# Output:

If no errors occur, the received response should look something like this:

"status": "Added: <#_of_versions_blocked>; Repeated: <#_of_versions_already_blocked>"
1

Note: These numbers do not give the total amount of versions blocked but how many of the versions in versions.json were added and how many of them were already blocked.

Important: This mechanism only works for version <insert_version_of_interceptor_after_MR> or newer.

# Error handling:

If an error occurs during the blocking process you should receive an error message, giving you a bit more insight on what went wrong.

Some of the more typical error messages, and possible fixes are:

  • # "error": "Not authorized":

The authentication process for your deployment failed. Please make sure that the "secret: <deployment_secret>" header is correct, and that the secret used is for your deployment.

  • # "error": "Bad request format":

The parsing process for your blocking request failed. Please unsure that your versions.json file is structured as shown above.

  • # "error": "Received versions in a wrong format. A well formatted version would be 0.6.2":

One or more versions were not well formatted. Please follow the format of the error message <number>.<number>.<number>

  • # "error": "Error while blocking versions":

There was an error while attempting to block the versions you requested. Please try again after a few minutes.