---
title: "Link a SharePoint file to a task (Onplana for SharePoint's document-library commands)"
method: POST
path: "/tasks/{id}/sharepoint-link"
tags: ["tasks"]
---

# Link a SharePoint file to a task (Onplana for SharePoint's document-library commands)

`POST /tasks/{id}/sharepoint-link`

## Request

- Base URL: `https://api.onplana.com/api`
- URL: `https://api.onplana.com/api/tasks/{id}/sharepoint-link`
- Auth: one of:
  - HTTP bearer
  - API key in header `Authorization`

Session only (personal and app tokens are refused). The caller must be allowed to attach files to the task. The url must be an https address on a SharePoint Online host, and the same host as the request's Origin, otherwise 400 ORIGIN_REQUIRED or ORIGIN_MISMATCH. The link is kept in the project's Project Documents folder, pointing back at the task. The same address already linked to the task answers 200 with created false.

## Path parameters

- `id` string, required

## Headers

- `X-Organization-Id` string, required

## Request body

- object
  - `name` string, required
  - `url` string, uri, required

## Response `200`

{ documentId, created: false }

## Other responses

- `201`: { documentId, created: true }
- `400`: Validation error
- `401`: Unauthorized - missing or invalid JWT

---

[API](https://skmtc.dev/onplana/apis/onplana-api.md) · [All operations](https://skmtc.dev/onplana/apis/onplana-api/llms.txt) · [OpenAPI document](https://skmtc.dev/onplana/apis/onplana-api/revisions/c3d6c89e9dc8?raw)
