Script Manager (REST)

Relativity Scripts allow for the execution of SQL scripts in the database(s) backing a Relativity instance. The Relativity Script Manager API exposes endpoints allowing for the programmatic interaction with scripts including:

  • Add script
  • Delete a script
  • Modify a script
  • Retrieve script input parameters
  • Preview a script
  • Import a script
  • Queue a script to run
  • Retrieve status of a script
  • Query action results
  • Export action results
  • Export script report
  • Clean up script results

The service may be used to create a standalone application that manages scripts across multiple environments or among workspaces in a single environment.

Contracts and data models related to the API are contained in Relativity.Extensibility.SDK.

You can also use the Script service through the .NET API. For more information, see Script Manager API.

This page contains the following information:

Postman sample file

You can use the Postman sample file to become familiar with making calls to endpoints on the Script Manager service. To download the sample file, click Script Manager Postman file.

To get started with Postman, complete these steps:

  1. Obtain access to a Relativity environment. You need a username and password to make calls to your environment.
  2. Install Postman.
  3. Import the Postman sample file for the service. For more information, see Working with data files on the Postman web site.
  4. Select an endpoint. Update the URL with the domain for your Relativity environment and any other variables.
  5. In the Authorization tab, set the Type to Basic Auth, enter your Relativity credentials, and click Update Request.
  6. See the following sections on this page for more information on setting required fields for a request.
  7. Click Send to make a request.

Guidelines for the Script Manager service

Review the following guidelines for working with this service.

The URLs for REST endpoints contain path parameters that you need to set before making a call:

  • Set the {versionNumber} placeholder to the version of the REST API that you want to use, using the format lowercase v and the version number, for example v1 or v2
  • Set other path parameters in the URLs to the Artifact ID of a given entity, for example setting {workspaceID} to the Artifact ID of a workspace.
  • Note: To indicate the admin-level context, set the {workspaceID} path parameter to -1.

Client code sample

public async Task<int> CreateScriptAsync()
    int scriptID = 0;
    using (Relativity.Extensibility.{versionNumber}.Scripts.IScriptManager scriptManager = serviceFactory.CreateProxy<Relativity.Extensibility.{versionNumber}.Scripts.IScriptManager>())
    using (HttpClient client = new HttpClient())
        client.DefaultRequestHeaders.Add("X-CSRF-Header", "-");
        client.DefaultRequestHeaders.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes("<user login>:<user password>")));
        client.DefaultRequestHeaders.Add("X-Kepler-Version", "2.0");
        client.BaseAddress = new Uri("http://<host name>/");
        string inputJSON = @"{""ScriptRequest"":{""ScriptBody"":""<script><name>My script Name</name><description>About my script</description><category></category><input> <constant id=\""count\"" name=\""Rows\"" type=\""number\"" /></input><display type =\""itemlist\""/><action returns =\""table\""><![CDATA[ SELECT TOP(CAST(#count# AS INT)) * FROM [eddsdbo].[Artifact] ]]></action></script>"",""RelativityApplications"": []}}";
        string url = "/{versionNumber}/workspaces/-1/scripts";
        HttpResponseMessage response = await client.PostAsync(url, new StringContent(inputJSON, Encoding.UTF8, "application/json"));
        string content = await response.Content.ReadAsStringAsync();
        scriptID = Int32.Parse(content);
    return scriptID;

Add a script

Read script

Update script

Delete script

Import script

Get script parameters

Preview script

Enqueue run job

Read run job

Query action job results

Export action results

Export script report

Clean up run job