---
title: "Put Attachment Operation"
url: "https://docs.ravendb.net/6.2/client-api/operations/attachments/put-attachment"
version: "6.2"
language: "csharp"
---

# Put Attachment Operation

> Client language: C#. Also available for [Java](https://docs.ravendb.net/6.2/client-api/operations/attachments/put-attachment.java.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/attachments/put-attachment.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

This operation is used to put an attachment to a document.

## Syntax

```csharp
public PutAttachmentOperation(string documentId, 
      string name, 
      Stream stream, 
      string contentType = null, 
      string changeVector = null)
```

```csharp
public class AttachmentDetails : AttachmentName
{
  public string ChangeVector;
  public string DocumentId;
}

public class AttachmentName
{
  public string Name;
  public string Hash;
  public string ContentType;
  public long Size;
}
```

| Parameter | | |
| - | - | - |
| **documentId** | string | ID of a document which will contain an attachment |
| **name** | string | Name of an attachment |
| **stream** | Stream | Stream contains attachment raw bytes |
| **contentType** | string | MIME type of attachment |
| **changeVector** | string | Entity changeVector, used for concurrency checks (`null` to skip check) |

| Return Value | |
| - | - |
| **ChangeVector** | Change vector of created attachment |
| **DocumentId** | ID of document |
| **Name** | Name of created attachment |
| **Hash** | Hash of created attachment |
| **ContentType** | MIME content type of attachment |
| **Size** | Size of attachment |

## Example

```csharp
AttachmentDetails attachmentDetails =
  store.Operations.Send(
      new PutAttachmentOperation("orders/1-A",
          "invoice.pdf",
          stream,
          "application/pdf"));
```

## See also

- [What are operations](https://docs.ravendb.net/6.2/client-api/operations/what-are-operations.md)
- [Get attachment](https://docs.ravendb.net/6.2/client-api/operations/attachments/get-attachment.md)
- [Delete attachment](https://docs.ravendb.net/6.2/client-api/operations/attachments/delete-attachment.md)
