Skip to main content

Zammad API Client

PyPI version Documentation Status

Python API client for zammad

Quickstart

from zammad_py import ZammadAPI

# Initialize the client with the URL, username, and password
# Note the Host URL should be in this format: 'https://zammad.example.org/api/v1/'
client = ZammadAPI(url='<HOST>', username='<USERNAME>', password='<PASSWORD>')

# Example: Access all users
this_page = client.user.all()
for user in this_page:
    print(user)

# Example: Get information about the current user
print(client.user.me())

# Example: Create a ticket
params = {
   "title": "Help me!",
   "group": "2nd Level",
   "customer": "david@example.com",
   "article": {
      "subject": "My subject",
      "body": "I am a message!",
      "type": "note",
      "internal": False
   }
}
new_ticket = client.ticket.create(params=params)

General Methods

Most resources support these methods:

  • .all(): Returns a paginated response with the current page number and a list of elements.
  • .next_page(): Returns the next page of the current pagination object.
  • .prev_page(): Returns the previous page of the current pagination object.
  • .search(params): Returns a paginated response based on the search parameters.
  • .find(id): Returns a single object with the specified ID.
  • .create(params): Creates a new object with the specified parameters.
  • .update(params): Updates an existing object with the specified parameters.
  • .destroy(id): Deletes an object with the specified ID.

Available Resources

Resource Property
User client.user
Organization client.organization
Group client.group
Role client.role
Ticket client.ticket
Link client.link
TicketArticle client.ticket_article
TicketArticleAttachment client.ticket_article_attachment
TicketArticlePlain client.ticket_article_plain
TicketPriority client.ticket_priority
TicketState client.ticket_state
TagList client.taglist
TicketTag client.ticket_tag
KnowledgeBases client.knowledge_bases
KnowledgeBasesAnswers client.knowledge_bases_answers
KnowledgeBasesCategories client.knowledge_bases_categories

Resource-Specific Methods

User

  • .me(): Returns information about the current user.

Ticket

  • .articles(id): Returns all articles associated with a ticket.
  • .tags(id): Returns all tags associated with a ticket.
  • .merge(id, number): Merges two tickets (requires password auth).

Link

  • .get(id): Returns all links associated with a ticket.
  • .add(...): Creates a link between two objects.
  • .remove(...): Removes a link between two objects.

TicketArticleAttachment

  • .download(id, article_id, ticket_id): Downloads a ticket attachment.

TagList

  • .all(): Returns all tags (paginated).
  • .create(params): Creates a new tag.
  • .destroy(id): Deletes a tag.

TicketTag

  • .add(id, tag): Adds a tag to a ticket.
  • .remove(id, tag): Removes a tag from a ticket.

KnowledgeBases

  • .init(): Returns the entire knowledge base structure.
  • .manage(id, settings): Updates knowledge base settings.
  • .show_permissions(id): Returns permissions for a knowledge base.
  • .change_permissions(id, permissions): Updates permissions.
  • .reorder_sub_categories(id, category_id, params): Reorders sub-categories.
  • .reorder_root_categories(id, params): Reorders root categories.

KnowledgeBasesAnswers

  • .find_answer(knowledge_base_id, answer_id): Retrieves a specific answer.
  • .create(params): Creates a new answer (requires knowledge_base_id in params).
  • .update(id, params): Updates an answer (requires answer_id in params).
  • .destroy_answer(knowledge_base_id, answer_id): Deletes an answer.
  • .change_answer_visibility(knowledge_base_id, answer_id, visibility): Updates answer visibility.
  • .add_attachment(knowledge_base_id, answer_id, attachment): Uploads an attachment.
  • .delete_attachment(knowledge_base_id, answer_id, attachment_id): Removes an attachment.

KnowledgeBasesCategories

  • .find_category(knowledge_base_id, category_id): Retrieves a specific category.
  • .create(params): Creates a new category (requires knowledge_base_id in params).
  • .update(id, params): Updates a category (requires category_id in params).
  • .destroy_category(knowledge_base_id, category_id): Deletes a category.
  • .show_permissions(knowledge_base_id, category_id): Returns category permissions.
  • .change_permissions(knowledge_base_id, category_id, permissions): Updates permissions.
  • .reorder_answers(knowledge_base_id, category_id, params): Reorders answers.

On Behalf Of

You can set the on_behalf_of attribute to perform actions on behalf of another user:

client.on_behalf_of = 'user@example.com'

Or use the context manager:

with client.request_on_behalf_of('user@example.com'):
    client.ticket.create(params=params)

Contributing

The Zammad API Client (zammad_py) welcomes contributions.

You can contribute by reporting bugs, fixing bugs, implementing new features, writing documentation, and submitting feedback.

To get started, see the contributing section in the docs!

Please ensure that your changes include tests and updated documentation if necessary.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Metadata

Release files for zammad_py 3.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zammad_py 3.2.1
File Size Uploaded
zammad_py-3.2.1.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zammad_py 3.2.1
File Interpreter ABI Platform
zammad_py-3.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / zammad_py-3.2.1.tar.gz

Download URL zammad_py-3.2.1.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7ed3f57c181efddcb68eee008ae41c54b18701c0b53ac8f5cbf0f602088f587f
BLAKE2b-256 checksum
How to use checksums
c1f592d4f9ee8e40f12095f50eddc1c5b7f575a9154dc4a674e1f5287afb5531
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.13.11 Linux/6.18.7-100.fc42.x86_64

Release files / zammad_py-3.2.1-py3-none-any.whl

Download URL zammad_py-3.2.1-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93158fabbdb033d0c60470dcd85179fbfa36792693abe3d188f93c55a81a57b5
BLAKE2b-256 checksum
How to use checksums
f3171d5601dda084477fafa9322e5e60c6f4fa16a43751db3b5331ab88334e77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.13.11 Linux/6.18.7-100.fc42.x86_64

Release history Release notifications | RSS feed

This release

3.2.1 This release

2 release files

3.2.0

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.1

1 release file

1.0.0

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page