> For the complete documentation index, see [llms.txt](https://docs.geosamples.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.geosamples.org/api/related-resources.md).

# Related Resources

## List related resources

> Paginated related resources for the current user by default, or team-scoped when \`uploaded\_by\_team\` is set. Filter by \`related\_resource\_type\`, \`related\_resource\_type\_label\`, or \`search\`.

```json
{"openapi":"3.0.3","info":{"title":"SESAR API","version":"1.0.0"},"security":[{"tokenAuth":[]},{"jwtAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""},"jwtAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"PaginatedRelatedResourceListPaginationList":{"type":"object","required":["count","results"],"properties":{"count":{"type":"integer"},"next":{"type":"string","nullable":true,"format":"uri"},"previous":{"type":"string","nullable":true,"format":"uri"},"results":{"type":"array","items":{"$ref":"#/components/schemas/RelatedResourceListPagination"}}}},"RelatedResourceListPagination":{"type":"object","properties":{"count":{"type":"integer"},"next":{"type":"string","nullable":true},"previous":{"type":"string","nullable":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/RelatedResource"}},"page_size":{"type":"integer"},"current_page":{"type":"integer"},"total_pages":{"type":"integer","nullable":true}},"required":["count","data"]},"RelatedResource":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"label":{"type":"string","maxLength":255},"description":{"type":"string","nullable":true},"related_resource_type":{"type":"string","readOnly":true},"uri":{"type":"string","maxLength":255},"uri_type":{"type":"string","maxLength":24},"file_type":{"type":"string","nullable":true,"maxLength":128},"uploaded_date":{"type":"string","format":"date-time"}},"required":["id","label","related_resource_type","uri","uri_type"]}}},"paths":{"/api/related-resources/":{"get":{"operationId":"related_resources_list","description":"Paginated related resources for the current user by default, or team-scoped when `uploaded_by_team` is set. Filter by `related_resource_type`, `related_resource_type_label`, or `search`.","summary":"List related resources","parameters":[{"in":"query","name":"ordering","schema":{"type":"string"},"description":"Sort field; prefix with `-` for descending. Allowed: uploaded_date, label."},{"in":"query","name":"page","schema":{"type":"integer"},"description":"Page number (1-based)."},{"in":"query","name":"page_size","schema":{"type":"integer"},"description":"Items per page (max 2000)."},{"in":"query","name":"related_resource_type","schema":{"type":"integer"},"description":"Filter by related resource type primary key."},{"in":"query","name":"related_resource_type_label","schema":{"type":"string"},"description":"Filter by type label (case-insensitive). Use `Other` for resources whose type is not JournalArticle, Dataset, or Image."},{"in":"query","name":"search","schema":{"type":"string"},"description":"Substring match on resource label or linked sample IGSN."},{"in":"query","name":"uploaded_by_team","schema":{"type":"integer"},"description":"When set, list resources uploaded by this team."}],"tags":["Related resources"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedRelatedResourceListPaginationList"}}},"description":""}}}}}}
```

## Create related resource

> Creates a related resource from a file upload (multipart) or URI metadata (JSON). Ownership defaults to the current user unless \`uploaded\_by\_team\` is set.

```json
{"openapi":"3.0.3","info":{"title":"SESAR API","version":"1.0.0"},"security":[{"tokenAuth":[]},{"jwtAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""},"jwtAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"RelatedResourceWrite":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"label":{"type":"string","maxLength":255},"description":{"type":"string","nullable":true},"related_resource_type":{"type":"string","nullable":true},"uri":{"type":"string","nullable":true},"uri_type":{"type":"string","nullable":true},"file_type":{"type":"string","nullable":true,"maxLength":128},"file_size":{"type":"integer","maximum":9223372036854776000,"minimum":-9223372036854776000,"format":"int64","nullable":true},"uploaded_date":{"type":"string","format":"date-time"},"uploaded_by":{"type":"integer","readOnly":true,"nullable":true},"uploaded_by_team":{"type":"integer","nullable":true},"file":{"type":"string","format":"uri","writeOnly":true,"nullable":true}},"required":["id","label","uploaded_by"]},"RelatedResourceCreateSuccessResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/RelatedResource"}},"required":["data"]},"RelatedResource":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"label":{"type":"string","maxLength":255},"description":{"type":"string","nullable":true},"related_resource_type":{"type":"string","readOnly":true},"uri":{"type":"string","maxLength":255},"uri_type":{"type":"string","maxLength":24},"file_type":{"type":"string","nullable":true,"maxLength":128},"uploaded_date":{"type":"string","format":"date-time"}},"required":["id","label","related_resource_type","uri","uri_type"]}}},"paths":{"/api/related-resources/":{"post":{"operationId":"related_resources_create","description":"Creates a related resource from a file upload (multipart) or URI metadata (JSON). Ownership defaults to the current user unless `uploaded_by_team` is set.","summary":"Create related resource","tags":["Related resources"],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/RelatedResourceWrite"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/RelatedResourceWrite"}},"application/json":{"schema":{"$ref":"#/components/schemas/RelatedResourceWrite"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelatedResourceCreateSuccessResponse"}}},"description":""}}}}}}
```

## GET /api/related-resources/{id}/

> Retrieve related resource

```json
{"openapi":"3.0.3","info":{"title":"SESAR API","version":"1.0.0"},"security":[{"tokenAuth":[]},{"jwtAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""},"jwtAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"RelatedResourceDetailSuccessResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/RelatedResource"}},"required":["data"]},"RelatedResource":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"label":{"type":"string","maxLength":255},"description":{"type":"string","nullable":true},"related_resource_type":{"type":"string","readOnly":true},"uri":{"type":"string","maxLength":255},"uri_type":{"type":"string","maxLength":24},"file_type":{"type":"string","nullable":true,"maxLength":128},"uploaded_date":{"type":"string","format":"date-time"}},"required":["id","label","related_resource_type","uri","uri_type"]}}},"paths":{"/api/related-resources/{id}/":{"get":{"operationId":"related_resources_retrieve","summary":"Retrieve related resource","parameters":[{"in":"path","name":"id","schema":{"type":"integer"},"required":true}],"tags":["Related resources"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelatedResourceDetailSuccessResponse"}}},"description":""}}}}}}
```

## Delete related resource

> Deletes the resource, subtracts storage quota, and removes the local file when applicable.

```json
{"openapi":"3.0.3","info":{"title":"SESAR API","version":"1.0.0"},"security":[{"tokenAuth":[]},{"jwtAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""},"jwtAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"RelatedResourceDeleteSuccessResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/RelatedResourceDeleteSuccessData"}},"required":["data"]},"RelatedResourceDeleteSuccessData":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}},"paths":{"/api/related-resources/{id}/":{"delete":{"operationId":"related_resources_destroy","description":"Deletes the resource, subtracts storage quota, and removes the local file when applicable.","summary":"Delete related resource","parameters":[{"in":"path","name":"id","schema":{"type":"integer"},"required":true}],"tags":["Related resources"],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelatedResourceDeleteSuccessResponse"}}},"description":""}}}}}}
```

## PATCH /api/related-resources/{id}/

> Update related resource

```json
{"openapi":"3.0.3","info":{"title":"SESAR API","version":"1.0.0"},"security":[{"tokenAuth":[]},{"jwtAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""},"jwtAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"PatchedRelatedResourceWrite":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"label":{"type":"string","maxLength":255},"description":{"type":"string","nullable":true},"related_resource_type":{"type":"string","nullable":true},"uri":{"type":"string","nullable":true},"uri_type":{"type":"string","nullable":true},"file_type":{"type":"string","nullable":true,"maxLength":128},"file_size":{"type":"integer","maximum":9223372036854776000,"minimum":-9223372036854776000,"format":"int64","nullable":true},"uploaded_date":{"type":"string","format":"date-time"},"uploaded_by":{"type":"integer","readOnly":true,"nullable":true},"uploaded_by_team":{"type":"integer","nullable":true},"file":{"type":"string","format":"uri","writeOnly":true,"nullable":true}}},"RelatedResourceUpdateSuccessResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/RelatedResource"}},"required":["data"]},"RelatedResource":{"type":"object","properties":{"id":{"type":"integer","readOnly":true},"label":{"type":"string","maxLength":255},"description":{"type":"string","nullable":true},"related_resource_type":{"type":"string","readOnly":true},"uri":{"type":"string","maxLength":255},"uri_type":{"type":"string","maxLength":24},"file_type":{"type":"string","nullable":true,"maxLength":128},"uploaded_date":{"type":"string","format":"date-time"}},"required":["id","label","related_resource_type","uri","uri_type"]}}},"paths":{"/api/related-resources/{id}/":{"patch":{"operationId":"related_resources_partial_update","summary":"Update related resource","parameters":[{"in":"path","name":"id","schema":{"type":"integer"},"required":true}],"tags":["Related resources"],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/PatchedRelatedResourceWrite"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/PatchedRelatedResourceWrite"}},"application/json":{"schema":{"$ref":"#/components/schemas/PatchedRelatedResourceWrite"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelatedResourceUpdateSuccessResponse"}}},"description":""}}}}}}
```

## Link or unlink samples

> Bulk link or unlink samples to a related resource. Use \`sample\_ids\` or \`select\_all\` with \`filters\` to resolve the sample set.

```json
{"openapi":"3.0.3","info":{"title":"SESAR API","version":"1.0.0"},"security":[{"tokenAuth":[]},{"jwtAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Token-based authentication with required prefix \"Token\""},"jwtAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"RelatedResourceSampleActionRequest":{"type":"object","properties":{"sample_ids":{"type":"array","items":{"type":"integer"},"description":"Sample primary keys to link or unlink."},"select_all":{"type":"boolean","default":false,"description":"When true, apply `filters` to resolve samples instead of `sample_ids`."},"filters":{"type":"object","additionalProperties":{"type":"string"},"description":"Sample list filters (same as sample list API) when `select_all` is true."}}},"RelatedResourceSampleActionSuccessResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/RelatedResourceSampleActionSuccessData"}},"required":["data"]},"RelatedResourceSampleActionSuccessData":{"type":"object","properties":{"message":{"type":"string"},"count":{"type":"integer"}},"required":["count","message"]}}},"paths":{"/api/related-resources/{id}/{action}/":{"post":{"operationId":"related_resources_create_2","description":"Bulk link or unlink samples to a related resource. Use `sample_ids` or `select_all` with `filters` to resolve the sample set.","summary":"Link or unlink samples","parameters":[{"in":"path","name":"action","schema":{"type":"string","enum":["link-samples","unlink-samples"]},"description":"Whether to link or unlink the resolved samples.","required":true},{"in":"path","name":"id","schema":{"type":"integer"},"required":true},{"in":"path","name":"pk","schema":{"type":"integer"},"description":"Related resource primary key.","required":true}],"tags":["Related resources"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelatedResourceSampleActionRequest"}},"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/RelatedResourceSampleActionRequest"}},"multipart/form-data":{"schema":{"$ref":"#/components/schemas/RelatedResourceSampleActionRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RelatedResourceSampleActionSuccessResponse"}}},"description":""},"400":{"description":"Invalid action or no samples to process."},"403":{"description":"Insufficient permission on this resource."},"404":{"description":"Related resource not found."},"500":{"description":"Unexpected error while updating sample links."}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.geosamples.org/api/related-resources.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
