createCase method

Future<CreateCaseResponse> createCase({
  1. required String domainId,
  2. required List<FieldValue> fields,
  3. required String templateId,
  4. String? clientToken,
  5. UserUnion? performedBy,
  6. Map<String, String>? tags,
})
Creates a case in the specified Cases domain. Case system and custom fields are taken as an array id/value pairs with a declared data types.

When creating a case from a template that has tag propagation configurations, the specified tags are automatically applied to the case.

The following fields are required when creating a case:

  • customer_id - You must provide the full customer profile ARN in this format: arn:aws:profile:your_AWS_Region:your_AWS_account ID:domains/your_profiles_domain_name/profiles/profile_ID
  • title

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter domainId : The unique identifier of the Cases domain.

Parameter fields : An array of objects with field ID (matching ListFields/DescribeField) and value union data.

Parameter templateId : A unique identifier of a template.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

Parameter tags : A map of of key-value pairs that represent tags on a resource. Tags are used to organize, track, or control access for this resource.

Implementation

Future<CreateCaseResponse> createCase({
  required String domainId,
  required List<FieldValue> fields,
  required String templateId,
  String? clientToken,
  UserUnion? performedBy,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'fields': fields,
    'templateId': templateId,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (performedBy != null) 'performedBy': performedBy,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/domains/${Uri.encodeComponent(domainId)}/cases',
    exceptionFnMap: _exceptionFns,
  );
  return CreateCaseResponse.fromJson(response);
}