For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.ivfprovider.com/ivf-agency-ap-is/surrogate/documents/llms.txt. For full documentation content, see https://docs.ivfprovider.com/ivf-agency-ap-is/surrogate/documents/llms-full.txt.

# Upload Documents

POST http://localhost:8000/api/surrogates/{id}/documents
Content-Type: multipart/form-data

Reference: https://docs.ivfprovider.com/ivf-agency-ap-is/surrogate/documents/upload-documents

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/surrogates/{id}/documents:
    post:
      operationId: upload-documents
      summary: Upload Documents
      tags:
        - subpackage_surrogate.subpackage_surrogate/documents
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Surrogate_Documents_Upload
                  Documents_Response_200
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                type:
                  type: string
                document_title:
                  type: string
                documents[0][file]:
                  type: string
                  format: binary
                document_id:
                  type: string
                description:
                  type: string
              required:
                - type
                - document_title
                - documents[0][file]
                - document_id
                - description
servers:
  - url: http://localhost:8000
components:
  schemas:
    Surrogate_Documents_Upload Documents_Response_200:
      type: object
      properties:
        status:
          type: integer
        message:
          type: string
      required:
        - status
        - message
      title: Surrogate_Documents_Upload Documents_Response_200
  securitySchemes:
    oauth2Auth:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python Surrogate_Documents_Upload Documents_example
import requests

url = "http://localhost:8000/api/surrogates/19/documents"

files = { "documents[0][file]": "open('string', 'rb')" }
payload = {
    "type": "string",
    "document_title": "string",
    "document_id": "string",
    "description": "string"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())
```

```javascript Surrogate_Documents_Upload Documents_example
const url = 'http://localhost:8000/api/surrogates/19/documents';
const form = new FormData();
form.append('type', 'string');
form.append('document_title', 'string');
form.append('documents[0][file]', 'string');
form.append('document_id', 'string');
form.append('description', 'string');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Surrogate_Documents_Upload Documents_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:8000/api/surrogates/19/documents"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_title\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documents[0][file]\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Surrogate_Documents_Upload Documents_example
require 'uri'
require 'net/http'

url = URI("http://localhost:8000/api/surrogates/19/documents")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_title\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documents[0][file]\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n"

response = http.request(request)
puts response.read_body
```

```java Surrogate_Documents_Upload Documents_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:8000/api/surrogates/19/documents")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_title\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documents[0][file]\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n")
  .asString();
```

```php Surrogate_Documents_Upload Documents_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8000/api/surrogates/19/documents', [
  'multipart' => [
    [
        'name' => 'type',
        'contents' => 'string'
    ],
    [
        'name' => 'document_title',
        'contents' => 'string'
    ],
    [
        'name' => 'documents[0][file]',
        'filename' => 'string',
        'contents' => null
    ],
    [
        'name' => 'document_id',
        'contents' => 'string'
    ],
    [
        'name' => 'description',
        'contents' => 'string'
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Surrogate_Documents_Upload Documents_example
using RestSharp;

var client = new RestClient("http://localhost:8000/api/surrogates/19/documents");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_title\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"documents[0][file]\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"document_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Surrogate_Documents_Upload Documents_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "type",
    "value": "string"
  ],
  [
    "name": "document_title",
    "value": "string"
  ],
  [
    "name": "documents[0][file]",
    "fileName": "string"
  ],
  [
    "name": "document_id",
    "value": "string"
  ],
  [
    "name": "description",
    "value": "string"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8000/api/surrogates/19/documents")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```