Namespace: microsoft.graph.security.caseManagement
Important
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Create attachment metadata for a case. This method doesn't upload the file content. After creating the attachment, use Upload attachment content.
This API is available in the following national cloud deployments.
| Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
| Permission type |
Least privileged permissions |
Higher privileged permissions |
| Delegated (work or school account) |
CaseManagement.ReadWrite.All |
Not available. |
| Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
| Application |
CaseManagement.ReadWrite.All |
Not available. |
Important
For delegated access using work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role that grants the permissions required for this operation. This API supports the following built-in roles:
- Global Reader
- Security Reader
- Security Operator
- Security Administrator
HTTP request
POST /security/caseManagement/cases/{caseId}/attachments
Request body
In the request body, supply a JSON representation of the microsoft.graph.security.caseManagement.attachment object.
You can specify the following properties when creating an attachment.
| Property |
Type |
Description |
| description |
String |
The description of the resource. Optional. |
| displayName |
String |
The display name of the attachment. The value must be unique among attachments in the same case; creating another attachment with the same display name isn't allowed. Required. |
| fileExtension |
String |
The file extension of the attachment. The service normalizes the value to include a leading period. Optional. |
| fileSize |
Int64 |
The size of the attachment in bytes. The maximum file size is 100 MB. Required. |
The origin and scanResult properties are service controlled and can't be supplied.
Response
If successful, this method returns a 201 Created response code and a microsoft.graph.security.caseManagement.attachment object in the response body.
Examples
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/security/caseManagement/cases/{caseId}/attachments
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.security.caseManagement.attachment",
"displayName": "Case MS-001 Attachment",
"description": "Screenshot of suspicious sign-in activity",
"fileSize": 1000,
"fileExtension": "jpeg"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models.Security.CaseManagement;
var requestBody = new Attachment
{
OdataType = "#microsoft.graph.security.caseManagement.attachment",
DisplayName = "Case MS-001 Attachment",
Description = "Screenshot of suspicious sign-in activity",
FileSize = 1000L,
FileExtension = "jpeg",
ScanResult = AttachmentScanResult.NoThreatsFound,
Origin = new AttachmentOrigin
{
OdataType = "microsoft.graph.security.caseManagement.attachmentOrigin",
ResourceId = "987757fb-6ef4-1061-17e7-9de0d088e1dd",
ResourceType = AttachmentOriginType.Case,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Security.CaseManagement.Cases["{case-id}"].Attachments.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodelssecuritycasemanagement "github.com/microsoftgraph/msgraph-beta-sdk-go/models/security/casemanagement"
//other-imports
)
requestBody := graphmodelssecuritycasemanagement.NewAttachment()
displayName := "Case MS-001 Attachment"
requestBody.SetDisplayName(&displayName)
description := "Screenshot of suspicious sign-in activity"
requestBody.SetDescription(&description)
fileSize := int64(1000)
requestBody.SetFileSize(&fileSize)
fileExtension := "jpeg"
requestBody.SetFileExtension(&fileExtension)
scanResult := graphmodels.NOTHREATSFOUND_ATTACHMENTSCANRESULT
requestBody.SetScanResult(&scanResult)
origin := graphmodelssecuritycasemanagement.NewAttachmentOrigin()
resourceId := "987757fb-6ef4-1061-17e7-9de0d088e1dd"
origin.SetResourceId(&resourceId)
resourceType := graphmodels.CASE_ATTACHMENTORIGINTYPE
origin.SetResourceType(&resourceType)
requestBody.SetOrigin(origin)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
attachments, err := graphClient.Security().CaseManagement().Cases().ByCaseId("case-id").Attachments().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.models.security.casemanagement.Attachment attachment = new com.microsoft.graph.beta.models.security.casemanagement.Attachment();
attachment.setOdataType("#microsoft.graph.security.caseManagement.attachment");
attachment.setDisplayName("Case MS-001 Attachment");
attachment.setDescription("Screenshot of suspicious sign-in activity");
attachment.setFileSize(1000L);
attachment.setFileExtension("jpeg");
attachment.setScanResult(com.microsoft.graph.beta.models.security.casemanagement.AttachmentScanResult.NoThreatsFound);
com.microsoft.graph.beta.models.security.casemanagement.AttachmentOrigin origin = new com.microsoft.graph.beta.models.security.casemanagement.AttachmentOrigin();
origin.setOdataType("microsoft.graph.security.caseManagement.attachmentOrigin");
origin.setResourceId("987757fb-6ef4-1061-17e7-9de0d088e1dd");
origin.setResourceType(com.microsoft.graph.beta.models.security.casemanagement.AttachmentOriginType.Case);
attachment.setOrigin(origin);
com.microsoft.graph.models.security.casemanagement.Attachment result = graphClient.security().caseManagement().cases().byCaseId("{case-id}").attachments().post(attachment);
const options = {
authProvider,
};
const client = Client.init(options);
const attachment = {
'@odata.type': '#microsoft.graph.security.caseManagement.attachment',
displayName: 'Case MS-001 Attachment',
description: 'Screenshot of suspicious sign-in activity',
fileSize: 1000,
fileExtension: 'jpeg',
scanResult: 'noThreatsFound',
origin: {
'@odata.type': 'microsoft.graph.security.caseManagement.attachmentOrigin',
resourceId: '987757fb-6ef4-1061-17e7-9de0d088e1dd',
resourceType: 'case'
}
};
await client.api('/security/caseManagement/cases/{caseId}/attachments')
.version('beta')
.post(attachment);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Security\CaseManagement\Attachment;
use Microsoft\Graph\Beta\Generated\Models\Security\CaseManagement\AttachmentScanResult;
use Microsoft\Graph\Beta\Generated\Models\Security\CaseManagement\AttachmentOrigin;
use Microsoft\Graph\Beta\Generated\Models\Security\CaseManagement\AttachmentOriginType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Attachment();
$requestBody->setOdataType('#microsoft.graph.security.caseManagement.attachment');
$requestBody->setDisplayName('Case MS-001 Attachment');
$requestBody->setDescription('Screenshot of suspicious sign-in activity');
$requestBody->setFileSize(1000);
$requestBody->setFileExtension('jpeg');
$requestBody->setScanResult(new AttachmentScanResult('noThreatsFound'));
$origin = new AttachmentOrigin();
$origin->setOdataType('microsoft.graph.security.caseManagement.attachmentOrigin');
$origin->setResourceId('987757fb-6ef4-1061-17e7-9de0d088e1dd');
$origin->setResourceType(new AttachmentOriginType('case'));
$requestBody->setOrigin($origin);
$result = $graphServiceClient->security()->caseManagement()->cases()->byCaseId('case-id')->attachments()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.security.case_management.attachment import Attachment
from msgraph_beta.generated.models.attachment_scan_result import AttachmentScanResult
from msgraph_beta.generated.models.security.case_management.attachment_origin import AttachmentOrigin
from msgraph_beta.generated.models.attachment_origin_type import AttachmentOriginType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Attachment(
odata_type = "#microsoft.graph.security.caseManagement.attachment",
display_name = "Case MS-001 Attachment",
description = "Screenshot of suspicious sign-in activity",
file_size = 1000,
file_extension = "jpeg",
scan_result = AttachmentScanResult.NoThreatsFound,
origin = AttachmentOrigin(
odata_type = "microsoft.graph.security.caseManagement.attachmentOrigin",
resource_id = "987757fb-6ef4-1061-17e7-9de0d088e1dd",
resource_type = AttachmentOriginType.Case,
),
)
result = await graph_client.security.case_management.cases.by_case_id('case-id').attachments.post(request_body)
Response
The following example shows the response.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.security.caseManagement.attachment",
"id": "1719f11c-21e9-acf2-85db-ade533556fba",
"createdDateTime": "2026-05-20T11:12:28Z",
"createdBy": "user@contoso.com",
"lastModifiedDateTime": "2026-05-20T11:18:45Z",
"lastModifiedBy": "user@contoso.com",
"displayName": "Case MS-001 Attachment",
"description": "Screenshot of suspicious sign-in activity",
"fileSize": 1000,
"fileExtension": ".jpeg",
"scanResult": "unscanned"
}