Skip to content

put_identity_policy

put_identity_policy(
    identity: Identity,
    policy_name: PolicyName,
    policy: Policy,
    *,
    config_overrides: Optional[SESClientConfig] = None,
) -> PutIdentityPolicyResponse

Adds or updates a sending authorization policy for the specified identity (an email address or a domain).

This operation is for the identity owner only. If you have not verified the identity, it returns an error.

Sending authorization is a feature that enables an identity owner to authorize other senders to use its identities. For information about using sending authorization, see the Amazon SES Developer Guide.

You can execute this operation no more than once per second.

Parameters:

  • identity (Identity) –

    The identity to which that the policy applies. You can specify an identity by using its name or by using its Amazon Resource Name (ARN). Examples: [email protected], example.com, arn:aws:ses:us-east-1:123456789012:identity/example.com.

    To successfully call this operation, you must own the identity.

  • policy_name (PolicyName) –

    The name of the policy.

    The policy name cannot exceed 64 characters and can only include alphanumeric characters, dashes, and underscores.

  • policy (Policy) –

    The text of the policy in JSON format. The policy cannot exceed 4 KB.

    For information about the syntax of sending authorization policies, see the Amazon SES Developer Guide.

Raises:

  • InvalidPolicyException –

    Indicates that the provided policy is invalid. Check the error stack for more information about what caused the error.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

PutIdentityPolicy The following example adds a sending authorization policy to an identity:

>>> client.put_identity_policy(identity='example.com', policy_name='MyPolicy', policy='{"Version":"2008-10-17","Statement":[{"Sid":"stmt1469123904194","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:root"},"Action":["ses:SendEmail","ses:SendRawEmail"],"Resource":"arn:aws:ses:us-east-1:EXAMPLE65304:identity/example.com"}]}')
Source code in docs_src/capo_ses/_services/ses.py
def put_identity_policy(
    self,
    identity: "capo_ses.types.identity.Identity",
    policy_name: "capo_ses.types.policy_name.PolicyName",
    policy: "capo_ses.types.policy.Policy",
    *,
    config_overrides: Optional[SESClientConfig] = None,
) -> "capo_ses.types.put_identity_policy_response.PutIdentityPolicyResponse":
    """<p>Adds or updates a sending authorization policy for the specified identity (an email address or a domain).</p> <note> <p>This operation is for the identity owner only. If you have not verified the identity, it returns an error.</p> </note> <p>Sending authorization is a feature that enables an identity owner to authorize other senders to use its identities. For information about using sending authorization, see the <a href="https://docs.aws.amazon.com/ses/latest/dg/sending-authorization.html">Amazon SES Developer Guide</a>.</p> <p>You can execute this operation no more than once per second.</p>

    Args:
        identity: <p>The identity to which that the policy applies. You can specify an identity by using its name or by using its Amazon Resource Name (ARN). Examples: <code>[email protected]</code>, <code>example.com</code>, <code>arn:aws:ses:us-east-1:123456789012:identity/example.com</code>.</p> <p>To successfully call this operation, you must own the identity.</p>
        policy_name: <p>The name of the policy.</p> <p>The policy name cannot exceed 64 characters and can only include alphanumeric characters, dashes, and underscores.</p>
        policy: <p>The text of the policy in JSON format. The policy cannot exceed 4 KB.</p> <p>For information about the syntax of sending authorization policies, see the <a href="https://docs.aws.amazon.com/ses/latest/dg/sending-authorization-policies.html">Amazon SES Developer Guide</a>. </p>

    Raises:
        capo_ses.errors.invalid_policy_exception.InvalidPolicyException: <p>Indicates that the provided policy is invalid. Check the error stack for more information about what caused the error.</p>
        capo_ses.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        PutIdentityPolicy
        The following example adds a sending authorization policy to an identity:

        >>> client.put_identity_policy(identity='example.com', policy_name='MyPolicy', policy='{"Version":"2008-10-17","Statement":[{"Sid":"stmt1469123904194","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:root"},"Action":["ses:SendEmail","ses:SendRawEmail"],"Resource":"arn:aws:ses:us-east-1:EXAMPLE65304:identity/example.com"}]}')
    """

    def _handler(
        req: "OperationRequest[capo_ses.types.put_identity_policy_request.PutIdentityPolicyRequest]",
    ) -> OperationResponse[
        "capo_ses.types.put_identity_policy_response.PutIdentityPolicyResponse"
    ]:
        import capo_ses._operations.simple_email_service.put_identity_policy

        output, http_response = (
            capo_ses._operations.simple_email_service.put_identity_policy.put_identity_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutIdentityPolicy")
    )
    input_: capo_ses.types.put_identity_policy_request.PutIdentityPolicyRequest = {
        "identity": identity,
        "policy_name": policy_name,
        "policy": policy,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output