> For the complete documentation index, see [llms.txt](https://developers.incidents.cloud.solarwinds.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/sdks/postmortems.md).

# Incidents.Postmortems

## Overview

### Available Operations

* [DeleteByIncident](#deletebyincident) - Delete Postmortem By Incident
* [GetByIncident](#getbyincident) - Get Postmortem By Incident
* [Create](#create) - Create Postmortem

## DeleteByIncident

* This endpoint is used to delete a postmortem by incident.
* Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.Incidents.Postmortems.DeleteByIncident(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}
```

### Parameters

| Parameter    | Type                                                                                                              | Required             | Description                         |
| ------------ | ----------------------------------------------------------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`        | [context.Context](https://pkg.go.dev/context#Context)                                                             | :heavy\_check\_mark: | The context to use for the request. |
| `incidentID` | `string`                                                                                                          | :heavy\_check\_mark: | N/A                                 |
| `opts`       | \[][operations.Option](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.PostmortemsDeletePostmortemByIncidentResponse**](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/models/operations/postmortemsdeletepostmortembyincidentresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## GetByIncident

* This endpoint is used to get a postmortem by incident.
* Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.Incidents.Postmortems.GetByIncident(ctx, "<id>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}
```

### Parameters

| Parameter    | Type                                                                                                              | Required             | Description                         |
| ------------ | ----------------------------------------------------------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`        | [context.Context](https://pkg.go.dev/context#Context)                                                             | :heavy\_check\_mark: | The context to use for the request. |
| `incidentID` | `string`                                                                                                          | :heavy\_check\_mark: | N/A                                 |
| `opts`       | \[][operations.Option](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/models/operations/option.md) | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.PostmortemsGetPostmortemByIncidentResponse**](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/models/operations/postmortemsgetpostmortembyincidentresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |

## Create

* This endpoint is used to create a postmortem.
* Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header.

### Example Usage

```go
package main

import(
	"context"
	"os"
	squadcastsdk "github.com/solarwinds/squadcast-sdk-go"
	"github.com/solarwinds/squadcast-sdk-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := squadcastsdk.New(
        squadcastsdk.WithSecurity(os.Getenv("SQUADCASTSDK_REFRESH_TOKEN_AUTH")),
    )

    res, err := s.Incidents.Postmortems.Create(ctx, "<id>", components.V3IncidentsPostmortemsCreatePostmortemRequest{
        OwnerID: "<id>",
        Title: "<value>",
        Postmortem: "<value>",
        Status: components.V3IncidentsPostmortemsPostmortemStatusPublished,
        FollowUps: []components.V3IncidentsPostmortemsPostmortemFollowUp{},
        Attachments: []components.V3IncidentsPostmortemsPostmortemAttachmentRequest{
            components.V3IncidentsPostmortemsPostmortemAttachmentRequest{},
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Object != nil {
        // handle response
    }
}
```

### Parameters

| Parameter                                       | Type                                                                                                                                                                                         | Required             | Description                         |
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ----------------------------------- |
| `ctx`                                           | [context.Context](https://pkg.go.dev/context#Context)                                                                                                                                        | :heavy\_check\_mark: | The context to use for the request. |
| `incidentID`                                    | `string`                                                                                                                                                                                     | :heavy\_check\_mark: | N/A                                 |
| `v3IncidentsPostmortemsCreatePostmortemRequest` | [components.V3IncidentsPostmortemsCreatePostmortemRequest](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/models/components/v3incidentspostmortemscreatepostmortemrequest.md) | :heavy\_check\_mark: | N/A                                 |
| `opts`                                          | \[][operations.Option](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/models/operations/option.md)                                                                            | :heavy\_minus\_sign: | The options for this request.       |

### Response

[**\*operations.PostmortemsCreatePostmortemResponse**](https://developers.incidents.cloud.solarwinds.com/go-sdk/docs/models/operations/postmortemscreatepostmortemresponse.md)**, error**

### Errors

| Error Type                         | Status Code | Content Type     |
| ---------------------------------- | ----------- | ---------------- |
| apierrors.BadRequestError          | 400         | application/json |
| apierrors.UnauthorizedError        | 401         | application/json |
| apierrors.PaymentRequiredError     | 402         | application/json |
| apierrors.ForbiddenError           | 403         | application/json |
| apierrors.NotFoundError            | 404         | application/json |
| apierrors.ConflictError            | 409         | application/json |
| apierrors.UnprocessableEntityError | 422         | application/json |
| apierrors.InternalServerError      | 500         | application/json |
| apierrors.BadGatewayError          | 502         | application/json |
| apierrors.ServiceUnavailableError  | 503         | application/json |
| apierrors.GatewayTimeoutError      | 504         | application/json |
| apierrors.APIError                 | 4XX, 5XX    | \*/\*            |
