# Create a script in a project Creates a new script in the top level of the project project_id. If you want to create a script within a particular folder, please refer to Create a script in a folder POST /projects/:p/folders/:f/script, a nearly identical endpoint but for the specifying which folder to put the script in. Endpoint: POST /projects/{project_id}/scripts Version: 1.0 ## Path parameters: - `project_id` (integer, required) The project ID. ## Query parameters: - `insert` (string) Controls where the script will be created within the project: first (default) — the folder is placed at the top of the parent folder. last — the folder is placed at the end of the parent folder. N - integer — the folder is placed after the Nth item in the parent folder. ## Request fields (application/json): - `name` (string) The name of the script. Defaults to "New Script" if not supplied. - `description` (string) Optional description for the script. Left empty if not supplied. - `fields` (array) A list of field definitions, with three options for how to supply them: - as a string, used as the field ID or label, with IDs derived by converting spaces to underscores, and labels derived by converting underscores to spaces - as a parenthesized string, e.g. (field), which works as for a string-supplied field, except the parantheses imply the field should be show:false (i.e. hidden) - as an object - a FieldDef - `tests` (any) A collection of tests, each test a separate line of text. Supply test lines as one of: 1. a single multiline string, OR 1. an array of strings, OR 1. an array of objects (TestInput). - `runs` (array) List of runs to include with the script. - `runs.id` (integer) Run identifier - `runs.headers` (object) A map of header field IDs to their string values. Each property name is a header ID (for example "browser", "platform", or a built-in header such as "_tester"). Each property value is the header's value as a string. - `runs.results` (object, required) Map of test ID → result. Keys are test IDs (test numbers supplied as a string to work as an object key). Values are either a simple status ("pass", "fail" etc) or a ResultObject. ## Response 200 fields (application/json): - `id` (integer) The ID of the script, generated by the server. - `name` (string) The name of the script. - `description` (string) Description for the script. - `created` (string) The timestamp for when the script was created. - `archived` (boolean) Whether the script has been archived within its project or not. Note that if the project itself has been archived, this property might still say false - it only relates to whether the script has been archived within the project. - `fields` (array) A list of fields a script is using - `fields.id` (string, required) The field ID. Built-in field IDs start with _. User-supplied field IDs cannot start with _. (e.g. _run, _tester, _createdDate, _createdTime, _tags). - `fields.label` (string) The text displayed for the field (omit when referencing built-in fields as their label cannot be changed) - `fields.show` (boolean) Whether to show this field in summaries (default true). - `tests` (any) A collection of tests, each test a separate line of text. The format of the collection depends on the tests URL parameter (see [Common URL Parameters](/docs/common-parameters.md)). - `runs` (array) The list of test runs in a script. - `runs.id` (integer) The run identifier, might come back as a string in the form 1.1 if this is a retest test run - `runs.created` (string) The timestamp of when this test run was created - `runs.assignee` (object) An object describing who this test run has been assigned to - `runs.assignee.email` (string) the last email address that an invitation to make this test run was sent to (normally used for Guest Testing) - `runs.assignee.id` (string) the user ID of who this has been assigned to, or _anyone if not assigned - `runs.assignee.name` (string) the name of the assignee of this test run, either the name associated with a known user in the account, or an alias supplied for e.g. when guest testing - `runs.headers` (object) The header values for the header fields of a test run - `runs.headers._run` (string) Run identifier - `runs.headers._createdDate` (string) The date (day) this test run was created - `runs.headers._createdTime` (string) The time of day that this test run was created - `runs.headers._tags` (string) The value of the Tags Filter field, specifying which tags to use for filtering tests by tag - `runs.headers._tester` (string) The displayable name of the assignee of this test run, might be a user's name, or an alias if using Guest Testing - `runs.results` (object, required) Sparse map of the result values for tests in this script for a test run. The keys are the string version of a test row ID. The values are Result objects. - `progress` (any) Progress object — may be either terse or full format depending on the URL parameter progress.