Skip to main content

Available APIs

Following DevRaven APIs are available for use in your scripts during execution of API monitoring checks.

Context APIs

Context API allows settings values that stay available throughout the API monitoring check execution. You can use context APIs to set a value in Before Request Script and later read the value in After Request Script.


Allows setting and reading values from Context.

//Before Request script
//set context variables. txn_id is new context variable being added.
devraven.context.txn_id = '1234'

//After Request script
//read context variables again

//or assert with context variables

Test Parameters

Test Parameters specified for a test can be accessed via the following APIs.


Allows accessing the Test Parameters associated with a test

console.log(devraven.testParams.paramName); //prints the String value for paramName or undefined if not specified

console.log(devraven.testParams); //prints all the params

Request APIs

devraven.request allows changing request object before the HTTP request is executed during a monitoring run.


Set/change the HTTP method for the HTTP request in Before Request Script

devraven.request.method = 'POST'


Change the URL before the execution of http request in Before Request Script

devraven.request.url = '';


Set/change the current body for the HTTP request in Before Request Script

var payload = {'foo':'bar};
devraven.request.body = JSON.stringify(payload);


Replace all the headers or set a new header to existing headers in Before Request Script

//replaces all existing header values currently available
devraven.request.headers = {

//set a new header
devraven.request.headers['x-newheadername'] = 'value';

Response APIs

devraven.response allows reading response object after the execution of HTTP request during a API monitoring run.

Use this object to create complex assertions in After Request Script.


Status code of the HTTP request



Allows read response header values from the HTTP response.



HTTP response body as String.



HTTP response body as a JSON object. An empty object will be returned if the response is not a JSON object type.




Time taken to execute the HTTP request in milliseconds.

expect(devraven.response.responseTime); //response times less than 250ms

State Persistence APIs

persistValue(key, value)

Persists provided value to public ephemeral storage for retrieval later in any dependent tests.

key String - Key must be at least 10 characters in length up to 36 characters. We recommend using an UUID as a key.

value String - Value must not be blank or null, String type and can be up to 2000 characters in length.

//key must be between 10-36 characters, UUID is recommended
//value must be less than 2000 characters
await devraven.persistValue('MY_UNIQUE_KEY_HERE_123', 'value to be persisted');

Values persisted are purged at regular hourly intervals. Values stored are not secured and accessible publicly using the key. Do not persist credentials or any sensitive information to this storage.


Retrieves a previously persisted value using the provided key.

Returns null if a value is not set for the provided key.

const value = await devraven.retrieveValue('MY_UNIQUE_KEY_HERE_123')


Deletes a previously persisted value from Storage.

//if not explictly deleted, the value will be purged after ~1 hr interval
await devraven.deleteValue('MY_UNIQUE_KEY_HERE_123')