# Submissions

## Submission

<mark style="color:green;">`POST`</mark> `http://biostudy-prod.ebi.ac.uk:8788/submissions`

Perform a submission to BioStudies using the given page tab. Please be aware of the following:\
\- The given page tab should match the format specified in the *SUBMISSION\_TYPE* header\
\- Regardless of the chosen format to submit, the page tab document in the response will always be returned in JSON format\
\- Any referenced file should be either placed in the user folder or attached to the request using the *Files* parameter. Please have in mind that the amount of files that can be directly attached to the request is limited, if the submission has too many files, please place them in the user directory.\
\- If no accession number is provided, a new submission will be created and the corresponding accession number will be generated\
\- If an accession number is provided, the submission will be treated as a resubmission which will perform an update\
\
**Example For JSON submission:**\
`curl -X POST \`\
`-H "X-SESSION-TOKEN: <authToken>" \`\
`-H "Submission_Type: application/json" \`\
`-F 'Submission={ "type": "Submission", "accno": "S-BIAD1", "section": { "type": "Study" }  }'`

#### Query Parameters

| Name     | Type    | Description                                                                                                                                                            |
| -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| onBehalf | string  | In case the submission is performed on behalf of another user, the submission owner's email should be placed in this parameter.                                        |
| sse      | boolean | In case the submission is performed on behalf of another user, this parameter indicates whether a new user should be registered in case the given owner doesn't exist. |
| name     | string  | Name that will be used to create the new user in case the *"sse"* parameter is set to true.                                                                            |

#### Headers

| Name             | Type   | Description                                                                                                                                                         |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| X-SESSION-TOKEN  | string | User authentication token                                                                                                                                           |
| Submission\_Type | string | <p>Page tab format used to perform the submission. Accepted values based on the format are:<br>- JSON: application/json<br>- TSV: text/plain<br>- XML: text/xml</p> |

#### Request Body

| Name       | Type   | Description                                                                                                                                                                                                          |
| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|            | string | Submission page tab in the chosen format                                                                                                                                                                             |
| Submission | string | List of files to be attached to the submission                                                                                                                                                                       |
| fileMode   | string | <p>Indicates whether the files in the submission should be copied or moved from the user folder. The files will be copied by default.<br><br><strong>Accepted values:</strong><br><em>COPY</em><br><em>MOVE</em></p> |
| Attributes | string | List of attributes that allow overriding any value at the submission level in the submitted page tab. The values should be passed in the key=value format i.e. title=new title                                       |

{% tabs %}
{% tab title="200 " %}

```
{
  "type": "Submission",
  "accno": "S-BIAD1",
  "section": {
    "type": "Study"
  }
}
```

{% endtab %}

{% tab title="401 " %}

```
Full authentication is required for this endpoint
```

{% endtab %}
{% endtabs %}

## Direct Submission

<mark style="color:green;">`POST`</mark> `http://biostudy-prod.ebi.ac.uk:8788/submissions/direct`

Perform a submission to BioStudies using the page tab inside the given file. Please be aware of the following:\
\- The given page tab should match the format specified in the *SUBMISSION\_TYPE*  header\
\- Regardless of the chosen format to submit, the page tab document in the response will always be returned in JSON format\
\- Any referenced file should be either placed in the user folder or attached to the request using the *Files* parameter. Please have in mind that the amount of files that can be directly attached to the request is limited, if the submission has too many files, please place them in the user directory.\
\- If no accession number is provided, a new submission will be created and the corresponding accession number will be generated\
\- If an accession number is provided, the submission will be treated as a resubmission which will perform an update\
\
**Example For JSON submission:**\
`curl -X POST \`\
`-H "X-SESSION-TOKEN: <authToken>" \`\
`-H "Submission_Type: text/plain" \`\
`-F 'Submission=submission.tsv}'`

#### Query Parameters

| Name     | Type    | Description                                                                                                                                                            |
| -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| onBehalf | string  | In case the submission is performed on behalf of another user, the submission owner's email should be placed in this parameter.                                        |
| sse      | boolean | In case the submission is performed on behalf of another user, this parameter indicates whether a new user should be registered in case the given owner doesn't exist. |
| name     | string  | Name that will be used to create the new user in case the *"sse"* parameter is set to true.                                                                            |

#### Headers

| Name             | Type   | Description                                                                                                                                                         |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| X-SESSION-TOKEN  | string | User authentication token                                                                                                                                           |
| Submission\_Type | string | <p>Page tab format used to perform the submission. Accepted values based on the format are:<br>- JSON: application/json<br>- TSV: text/plain<br>- XML: text/xml</p> |

#### Request Body

| Name       | Type   | Description                                                                                                                                                                                                          |
| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Submission | string | Submission page tab in the chosen format                                                                                                                                                                             |
| Files      | string | List of files to be attached to the submission                                                                                                                                                                       |
| fileMode   | string | <p>Indicates whether the files in the submission should be copied or moved from the user folder. The files will be copied by default.<br><br><strong>Accepted values:</strong><br><em>COPY</em><br><em>MOVE</em></p> |
| Attributes | string | List of attributes that allow overriding any value at the submission level in the submitted page tab. The values should be passed in the key=value format i.e. title=new title                                       |

{% tabs %}
{% tab title="200 " %}

```
{
  "type": "Submission",
  "accno": "S-BIAD1",
  "section": {
    "type": "Study"
  }
}
```

{% endtab %}

{% tab title="401 " %}

```
Full authetication is required for this endpoint
```

{% endtab %}
{% endtabs %}

## Submission

<mark style="color:red;">`DELETE`</mark> `http://biostudy-prod.ebi.ac.uk:8788/submissions/{accNo}`

Deletes the submission with the given accession number

#### Path Parameters

| Name  | Type   | Description                 |
| ----- | ------ | --------------------------- |
| accNo | string | Submission accession number |

#### Headers

| Name            | Type   | Description               |
| --------------- | ------ | ------------------------- |
| X-SESSION-TOKEN | string | User authentication token |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}
