Skip to the documentation
Python

openemail.signatures

Every method in this namespace: its signature, its parameters, what it returns and an example.

Methods

The signatures each address keeps: list them, add one, rename or rewrite it, choose which one signs new mail and which one signs replies and forwards, copy one to other addresses, and delete it.

signatures.list()

List the signatures of the workspace or of one address, a page at a time

Scopessettings:readPages through results
Signature
def list(    *,    limit: int | None = None,    cursor: str | None = None,    address: str | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> Page[SignatureResource]

Returns one page of signatures, sorted by address and then oldest first. list_all collects every page into one list and iterate walks them lazily. An address keeps a list of named signatures, as its Signature tab in the app shows. At most one of them is the default for new mail (isDefault) and at most one the default for replies and forwards (isReplyDefault), and one signature can be both.

Give address= to read the signatures of one address, or of a catch-all with *@example.com. Without it the list holds every address. An address that only ever had the single signature of earlier versions shows it here as one signature called Signature, default for both.

emails.send adds the default of the address it sends from, and takes signatureId to add any other signature of that address instead.

Parameters

limitint

Page size, from 1 to 100. The server defaults to 25.

cursorstr

The nextCursor of the previous page, passed back as it came. Leave it out for the first page.

addressstr

One address, such as [email protected], or *@example.com for the catch-all of a domain. Left out, every address is listed.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

Page[SignatureResource], a dict with items, hasMore and nextCursor. Each item has id, address, name, html, isDefault, isReplyDefault, createdAt and updatedAt.

Example

from openemail import openemail page = openemail.signatures.list(address='[email protected]') for signature in page['items']:    print(        signature['name'],        'new mail' if signature['isDefault'] else '',        'replies' if signature['isReplyDefault'] else '',    )

Notes

  • A key or an app limited to particular addresses or domains sees only the signatures of the addresses it holds, and those of a catch-all only when it holds the domain whole.

  • An address that is not an address, or that names a whole domain with @example.com, is a 422 invalid_parameter.

  • The cursor is opaque and holds where the last row sat in this order, so a signature added or deleted between pages never breaks the walk. A cursor this list did not hand out is a 400 invalid_cursor.

Also available in

API
GET /signatures
TypeScript
signatures.list()
Ruby
signatures.list
PHP
signatures->list
Go
Signatures.List
Java
signatures().list
C#
Signatures.ListAsync
CLI
openemail signatures list

signatures.list_all()

Collect every signature into one list

Scopessettings:readPages through results
Signature
def list_all(    *,    limit: int | None = None,    cursor: str | None = None,    address: str | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> builtins.list[SignatureResource]

Walks every page of list and returns all signatures in one list, sorted by address and then oldest first. One request per page. Give address= to collect the signatures of one address or catch-all.

Parameters

limitint

Page size for each request, from 1 to 100. The server defaults to 25.

cursorstr

Starts the walk after this cursor instead of the first page.

addressstr

One address, or *@example.com for a catch-all. Left out, every address is collected.

api_keystr

Overrides the client API key for every page of this walk.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

list[SignatureResource] holding every signature.

Example

from openemail import openemail signatures = openemail.signatures.list_all(address='[email protected]')short = next((signature for signature in signatures if signature['name'] == 'Short'), None) if short is not None:    openemail.emails.send(        {            'from': '[email protected]',            'to': '[email protected]',            'subject': 'Quick note',            'text': 'See you on Thursday.',            'signatureId': short['id'],        }    )

Notes

  • If any page fails, the call raises and the signatures already fetched are discarded.

Also available in

API
GET /signatures
TypeScript
signatures.listAll()
Ruby
signatures.list_all
PHP
signatures->listAll
Go
Signatures.ListAll
Java
signatures().listAll
C#
Signatures.ListAllAsync

signatures.iterate()

Stream the signatures one at a time

Scopessettings:readPages through results
Signature
def iterate(    *,    limit: int | None = None,    cursor: str | None = None,    address: str | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> Iterator[SignatureResource]

Returns a generator that yields signatures one at a time, sorted by address and then oldest first, and requests the next page only once the current one is used up. Nothing is fetched until the loop starts, and breaking out of it stops the requests.

Parameters

limitint

Page size for each request, from 1 to 100. The server defaults to 25.

cursorstr

Starts the walk after this cursor instead of the first page.

addressstr

One address, or *@example.com for a catch-all. Left out, every address is walked.

api_keystr

Overrides the client API key for every page of this walk.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

Iterator[SignatureResource], a generator yielding one signature per step.

Example

from openemail import openemail for signature in openemail.signatures.iterate():    if signature['isDefault']:        print(signature['address'], 'signs new mail with', signature['name'])

Notes

  • The generator is lazy, so an abandoned loop costs only the pages you consumed.

Also available in

API
GET /signatures
TypeScript
signatures.iterate()
Ruby
signatures.iterate
PHP
signatures->iterate
Go
Signatures.Iterate
Java
signatures().iterate
C#
Signatures.IterateAsync

signatures.get()

Read one signature by id

Scopessettings:read
Signature
def get(    id: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> SignatureResource

Looks up a single signature and returns it in the same shape as a row of list: the address it belongs to, its name, its HTML and whether it is the default for new mail, for replies and forwards, for both or for neither.

Parameters

idstrRequired

Signature id, which starts with sig_.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

SignatureResource with id, address, name, html, isDefault, isReplyDefault, createdAt and updatedAt.

Example

from openemail import openemail signature = openemail.signatures.get('sig_8f2c1a9b7d3e4f60a1b2c3d4') print(signature['address'], signature['name'], signature['html'])

Notes

  • A missing signature raises OpenEmailApiError with is_not_found set to True and code resource_not_found. So does one on an address a narrowed key does not hold.

Also available in

API
GET /signatures/{id}
TypeScript
signatures.get()
Ruby
signatures.get
PHP
signatures->get
Go
Signatures.Get
Java
signatures().get
C#
Signatures.GetAsync
CLI
openemail signatures get

signatures.create()

Add a signature to an address

Scopessettings:write
Signature
def create(    body: SignatureInput,    *,    api_key: str | None = None,    timeout: float | None = None,) -> SignatureResource

Adds a signature to one address, or to a catch-all with *@example.com, and returns it as it is stored. name is what the app calls it and is unique on its address, whatever the case, so a second Work on the same address is a 409 signature_name_taken. html is sanitised the way outgoing mail is and has to keep some text or an image, so the stored HTML can differ from what you sent.

The first signature of an address becomes its default for new mail and for replies and forwards, unless isDefault or isReplyDefault says False. A later signature becomes a default only when you ask, and then takes that place from the signature that held it. An address holds at most 50 signatures, and the call past that is a 422 signature_limit_reached.

The address has to be one of the workspace, or a catch-all on a verified domain here with its catch-all on.

Parameters

body['address']strRequired

The address the signature is for, such as [email protected], or *@example.com for the catch-all of a domain.

body['name']strRequired

What the signature is called, trimmed, 1 to 80 characters. Unique on its address, whatever the case.

body['html']strRequired

The signature as HTML, at most 150,000 characters before and after sanitising. It has to keep some text or an image.

body['isDefault']bool

True makes it the signature of new mail from the address. Left out, only the first signature of an address becomes that.

body['isReplyDefault']bool

True makes it the signature of replies and forwards from the address. Left out, only the first signature of an address becomes that.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

SignatureResource with the new id, the trimmed name, the sanitised html, isDefault and isReplyDefault.

Example

from openemail import openemail signature = openemail.signatures.create(    {        'address': '[email protected]',        'name': 'Short',        'html': '<p>Ada<br>Acme Ltd</p>',        'isReplyDefault': True,    }) print(signature['id'], signature['isDefault'], signature['isReplyDefault'])

Notes

  • The SDK does not retry a create after a network failure. If you retry by hand after a lost response, a 409 signature_name_taken means the first attempt succeeded.

  • A key or an app limited to particular addresses or domains can only add to an address it holds, and to a catch-all only when it holds the domain whole. Anything else is a 422 capability_unsupported.

  • copy puts the same signature on other addresses.

Also available in

API
POST /signatures
TypeScript
signatures.create()
Ruby
signatures.create
PHP
signatures->create
Go
Signatures.Create
Java
signatures().create
C#
Signatures.CreateAsync
CLI
openemail signatures create

signatures.update()

Rename a signature, rewrite it or change what it is the default for

Scopessettings:write
Signature
def update(    id: str,    patch: SignaturePatch,    *,    api_key: str | None = None,    timeout: float | None = None,) -> SignatureResource

Changes a signature and returns it as it is stored. Send any of name, html, isDefault and isReplyDefault: a key left out stays as it is, and a patch with none of them is a 422.

'isDefault': True makes it the signature of new mail from its address in place of the one that was. 'isDefault': False takes that away when this signature held it, so new mail from the address goes out with no signature until another one is chosen. isReplyDefault does the same for replies and forwards. The two are independent, so one signature can sign new mail and another, shorter one the replies.

A new name another signature of the address already has, compared without case, is a 409 signature_name_taken. The HTML is sanitised again and has to keep some text or an image. A message that is already scheduled picks up the new HTML when it goes out.

Parameters

idstrRequired

Signature id, which starts with sig_.

patch['name']str

New name, trimmed, 1 to 80 characters. Left out, the name stays.

patch['html']str

New HTML, at most 150,000 characters before and after sanitising. Left out, the HTML stays.

patch['isDefault']bool

True makes it the default for new mail, False takes that away when it held it. Left out, nothing changes.

patch['isReplyDefault']bool

True makes it the default for replies and forwards, False takes that away when it held it. Left out, nothing changes.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

SignatureResource with the unchanged id and address and the new name, html, isDefault and isReplyDefault.

Example

from openemail import openemail saved = openemail.signatures.update('sig_8f2c1a9b7d3e4f60a1b2c3d4', {'isDefault': True}) print(saved['name'], saved['isDefault'])

Notes

  • The SDK retries this call after a network failure, since the same patch sent twice leaves the same signature.

  • settings.update with address= still takes signature: it rewrites the HTML of the default for new mail, and adds a signature called Signature when the address has no default.

Also available in

API
PATCH /signatures/{id}
TypeScript
signatures.update()
Ruby
signatures.update
PHP
signatures->update
Go
Signatures.Update
Java
signatures().update
C#
Signatures.UpdateAsync
CLI
openemail signatures update

signatures.delete()

Delete a signature

Scopessettings:write
Signature
def delete(    id: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> DeletedSignatureResource

Deletes a signature for good. When it was a default, that default is left empty, so mail it would have signed goes out with no signature until another one is chosen with update. A scheduled message that named it with signatureId carries the default of its address instead. There is no undo.

Parameters

idstrRequired

Signature id, which starts with sig_.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

DeletedSignatureResource with object set to signature, the id, the address, and deleted set to True.

Example

from openemail import openemail removed = openemail.signatures.delete('sig_8f2c1a9b7d3e4f60a1b2c3d4') print(removed['address'], removed['deleted'])

Notes

  • The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.

Also available in

API
DELETE /signatures/{id}
TypeScript
signatures.delete()
Ruby
signatures.delete
PHP
signatures->delete
Go
Signatures.Delete
Java
signatures().delete
C#
Signatures.DeleteAsync
CLI
openemail signatures delete

signatures.copy()

Copy a signature to other addresses

Scopessettings:write
Signature
def copy(    id: str,    body: SignatureCopy,    *,    api_key: str | None = None,    timeout: float | None = None,) -> builtins.list[SignatureResource]

Puts a copy of a signature on up to 500 other addresses or catch-alls, as Copy to other addresses does in the app, and returns the copies. An address that already has a signature with the same name, whatever the case, gets its HTML replaced, so copying again after an edit brings every copy up to date. Any other address gets a new signature with that name.

A copy becomes the default for new mail where isDefault is True and the default for replies and forwards where isReplyDefault is True. On an address that had no signature at all it becomes both unless you say False. Left out, the defaults of the other addresses stay as they are.

The address the signature is already on is skipped. Each copy is its own signature from then on, with its own id: editing the original later changes no copy until you copy again.

Parameters

idstrRequired

The signature to copy.

body['addresses']list[str]Required

1 to 500 addresses to copy it to. Each is one address or *@example.com for a catch-all.

body['isDefault']bool

True makes each copy the default for new mail on its address.

body['isReplyDefault']bool

True makes each copy the default for replies and forwards on its address.

api_keystr

Overrides the client API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

list[SignatureResource], one copy for each address, in the order given.

Example

from openemail import openemail copies = openemail.signatures.copy(    'sig_8f2c1a9b7d3e4f60a1b2c3d4',    {'addresses': ['[email protected]', '[email protected]'], 'isDefault': True},) for copy in copies:    print(copy['address'], copy['id'], copy['isDefault'])

Notes

  • The copies are written one address at a time. When an address is full, the call fails with 422 signature_limit_reached and the addresses before it keep their copy, so the same call can be sent again once there is room.

  • The SDK retries this call after a network failure, since copying twice leaves the same signatures.

  • A key or an app limited to particular addresses or domains can only copy to addresses it holds. One it does not hold fails the whole call with 422 capability_unsupported before anything is written.

Also available in

API
POST /signatures/{id}/copy
TypeScript
signatures.copy()
Ruby
signatures.copy
PHP
signatures->copy
Go
Signatures.Copy
Java
signatures().copy
C#
Signatures.CopyAsync
CLI
openemail signatures copy