Skip to content

Latest commit

 

History

History
150 lines (105 loc) · 11.3 KB

File metadata and controls

150 lines (105 loc) · 11.3 KB

EmailAndSmsTemplates

(EmailAndSmsTemplates)

Overview

Available Operations

  • Upsert - Update a template for a given type and slug ⚠️ Deprecated
  • Revert - Revert a template ⚠️ Deprecated
  • Preview - Preview changes to a template ⚠️ Deprecated

Upsert

Updates the existing template of the given type and slug

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.EmailAndSmsTemplates.UpsertAsync(
    templateType: Clerk.BackendAPI.Models.Operations.UpsertTemplatePathParamTemplateType.Sms,
    slug: "verification-code",
    requestBody: new UpsertTemplateRequestBody() {
        Name = "Verification Code",
        Subject = "Your Verification Code",
        Markup = "<p>Your code: {{code}}</p>",
        Body = "Use this code to verify your email: {{code}}",
        DeliveredByClerk = true,
        FromEmailName = "hello",
        ReplyToEmailName = "support",
    }
);

// handle response

Parameters

Parameter Type Required Description Example
TemplateType UpsertTemplatePathParamTemplateType ✔️ The type of template to update sms
Slug string ✔️ The slug of the template to update verification-code
RequestBody UpsertTemplateRequestBody N/A

Response

UpsertTemplateResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 402, 403, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

Revert

Reverts an updated template to its default state

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.EmailAndSmsTemplates.RevertAsync(
    templateType: Clerk.BackendAPI.Models.Operations.RevertTemplatePathParamTemplateType.Email,
    slug: "welcome-email"
);

// handle response

Parameters

Parameter Type Required Description Example
TemplateType RevertTemplatePathParamTemplateType ✔️ The type of template to revert email
Slug string ✔️ The slug of the template to revert welcome-email

Response

RevertTemplateResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 402, 404 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

Preview

Returns a preview of a template for a given template_type, slug and body

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.EmailAndSmsTemplates.PreviewAsync(
    templateType: "email",
    slug: "welcome-email",
    requestBody: new PreviewTemplateRequestBody() {
        Subject = "Welcome to our service!",
        Body = "Hi, thank you for joining our service.",
        FromEmailName = "hello",
        ReplyToEmailName = "support",
    }
);

// handle response

Parameters

Parameter Type Required Description Example
TemplateType string ✔️ The type of template to preview email
Slug string ✔️ The slug of the template to preview welcome-email
RequestBody PreviewTemplateRequestBody Required parameters

Response

PreviewTemplateResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*