- Create - Create attachment
- Update - Update attachment
- Delete - Delete attachment
- Find - Find attachments
Create a new attachment for a document
package main
import(
"context"
"os"
sdkgo "github.com/documenso/sdk-go"
"github.com/documenso/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
)
res, err := s.Documents.Attachments.Create(ctx, operations.DocumentAttachmentCreateRequest{
DocumentID: 7014.36,
Data: operations.DocumentAttachmentCreateData{
Label: "<value>",
Data: "https://cheerful-bourgeoisie.org/",
},
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.DocumentAttachmentCreateRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DocumentAttachmentCreateResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.DocumentAttachmentCreateBadRequestError | 400 | application/json |
| apierrors.DocumentAttachmentCreateUnauthorizedError | 401 | application/json |
| apierrors.DocumentAttachmentCreateForbiddenError | 403 | application/json |
| apierrors.DocumentAttachmentCreateInternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Update an existing attachment
package main
import(
"context"
"os"
sdkgo "github.com/documenso/sdk-go"
"github.com/documenso/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
)
res, err := s.Documents.Attachments.Update(ctx, operations.DocumentAttachmentUpdateRequest{
ID: "<id>",
Data: operations.DocumentAttachmentUpdateData{
Label: "<value>",
Data: "https://tinted-ceramics.biz",
},
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.DocumentAttachmentUpdateRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DocumentAttachmentUpdateResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.DocumentAttachmentUpdateBadRequestError | 400 | application/json |
| apierrors.DocumentAttachmentUpdateUnauthorizedError | 401 | application/json |
| apierrors.DocumentAttachmentUpdateForbiddenError | 403 | application/json |
| apierrors.DocumentAttachmentUpdateInternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Delete an attachment from a document
package main
import(
"context"
"os"
sdkgo "github.com/documenso/sdk-go"
"github.com/documenso/sdk-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
)
res, err := s.Documents.Attachments.Delete(ctx, operations.DocumentAttachmentDeleteRequest{
ID: "<id>",
})
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.DocumentAttachmentDeleteRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DocumentAttachmentDeleteResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.DocumentAttachmentDeleteBadRequestError | 400 | application/json |
| apierrors.DocumentAttachmentDeleteUnauthorizedError | 401 | application/json |
| apierrors.DocumentAttachmentDeleteForbiddenError | 403 | application/json |
| apierrors.DocumentAttachmentDeleteInternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Find all attachments for a document
package main
import(
"context"
"os"
sdkgo "github.com/documenso/sdk-go"
"log"
)
func main() {
ctx := context.Background()
s := sdkgo.New(
sdkgo.WithSecurity(os.Getenv("DOCUMENSO_API_KEY")),
)
res, err := s.Documents.Attachments.Find(ctx, 965.17)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
documentID |
float64 | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.DocumentAttachmentFindResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.DocumentAttachmentFindBadRequestError | 400 | application/json |
| apierrors.DocumentAttachmentFindUnauthorizedError | 401 | application/json |
| apierrors.DocumentAttachmentFindForbiddenError | 403 | application/json |
| apierrors.DocumentAttachmentFindNotFoundError | 404 | application/json |
| apierrors.DocumentAttachmentFindInternalServerError | 500 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |