createApiKey method

Future<CreateApiKeyResponse> createApiKey({
  1. required String apiId,
  2. String? description,
  3. int? expires,
})

Creates a unique key that you can distribute to clients who are executing your API.

May throw BadRequestException. May throw NotFoundException. May throw LimitExceededException. May throw UnauthorizedException. May throw LimitExceededException. May throw InternalFailureException. May throw ApiKeyLimitExceededException. May throw ApiKeyValidityOutOfBoundsException.

Parameter apiId : The ID for your GraphQL API.

Parameter description : A description of the purpose of the API key.

Parameter expires : The time from creation time after which the API key expires. The date is represented as seconds since the epoch, rounded down to the nearest hour. The default value for this parameter is 7 days from creation time. For more information, see .

Implementation

Future<CreateApiKeyResponse> createApiKey({
  required String apiId,
  String? description,
  int? expires,
}) async {
  ArgumentError.checkNotNull(apiId, 'apiId');
  final $payload = <String, dynamic>{
    if (description != null) 'description': description,
    if (expires != null) 'expires': expires,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v1/apis/${Uri.encodeComponent(apiId)}/apikeys',
    exceptionFnMap: _exceptionFns,
  );
  return CreateApiKeyResponse.fromJson(response);
}