docs: Document Batch add Contacts to Companies REST API endpoint - #593
promptless-for-oss wants to merge 13 commits into
Conversation
Add reference for POST /companies/batch/addcontacts (mautic/mautic PR #16512), covering the assignments request body, per-pair results, summary object, status values, batch size limit, and change-log behavior.
| HTTP request | ||
| ============ | ||
|
|
||
| .. vale on |
There was a problem hiding this comment.
Documented the new POST /companies/batch/addcontacts endpoint and its purpose from this PR. The route is defined in app/bundles/LeadBundle/Config/config.php (mautic_api_companybatchaddcontacts, POST only) and handled by CompanyApiController::batchAddContactsAction, which reads the assignments array from the request body.
Source: mautic/mautic#16512
| - object | ||
| - Overall counts for the batch | ||
|
|
||
| Each entry in ``results`` contains the following properties. |
There was a problem hiding this comment.
The per-pair status/message values and the summary counts (total, succeeded, failed) come from BatchCompanyContactAssignmentModel in this PR (hard-coded message constants; succeeded counts status-200 pairs, failed counts all others). Overall 200 on processed batches, 400/403 request-level errors, and the 500 returned when the batch exceeds api_batch_max_limit (default 200) via the inherited validateBatchPayload() are all verified against the PR's functional tests.
Source: mautic/mautic#16512
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions.
|
Thanks @adiati98! Addressed all three points:
Vale now runs clean on all changed lines. (There's one pre-existing Vale suggestion on line 441 about |
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions.
|
Thanks @adiati98! These property tables describe the |
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions.
Convert the plain-sentence 'Per-pair ``status`` values:' intro into a proper h5 (~) heading 'Per-pair ``status`` values', a peer of the existing 'The ``results`` entry properties' and 'The ``summary`` object properties' subsections under the h4 'Properties' section. Addresses @adiati98's review on PR mautic#593.
|
Thanks @adiati98! Addressed the remaining comment. The plain-sentence To clarify the question in your comment: that table describes the |
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions.
Address @adiati98's review on PR mautic#593: trim excess tildes on the three property-table h5 headings so each underline matches its heading text length.
|
@adiati98 Thanks for the review — done. I shortened the three heading underlines to match the reviewer suggestions exactly:
The changes are pushed to this branch. Vale is clean on the changed lines. |
…-log note Fix two factual errors surfaced by re-checking merged mautic/mautic PR #16512: - Over-limit batch requests return HTTP 400, not 500 (validateBatchPayload returns HTTP_BAD_REQUEST; testBatchAddContactsExceedsBatchLimit asserts 400). - The single-add 'Add Contact to Company' endpoint now also writes to the Company change log for each new assignment (event name 'API assignment' vs the batch endpoint's 'API batch assignment').
|
I noticed that some CI checks failed for this PR. I'm investigating whether the failures are caused by this suggestion. If they're unrelated or pre-existing, I'll leave this suggestion unchanged and create a separate suggestion if a standalone docs fix is needed. |
…tions Lengthen the three h5 subsection underlines under Properties to match their title text (including the literal backtick characters RST counts): 'The ``results`` entry properties' (32), 'The ``summary`` object properties' (33), and 'Per-pair ``status`` values' (26). The prior lengths were shorter than the titles, which Sphinx flags as malformed section markup. Verified with rst2html: no 'Title underline too short' warnings remain.
…t subsections" This reverts commit be4345d.
|
@promptless-for-oss please rebase to 7.3 branch. |
|
In reply to this discussion Thanks @adiati98 — on it. I'll rebase this onto the 7.3 branch and update the PR, then follow up here once it's done. |
|
In reply to this discussion Done, @adiati98 — PR #593 now targets the |
|
@promptless-for-oss please create a PR to cherry-pick the changes here for 8.0 branch. |
|
In reply to this discussion On it — I'll prepare a PR that cherry-picks these Batch add Contacts to Companies REST API docs onto the 8.0 branch and follow up here with the link. |
|
In reply to this discussion Done — I've opened a PR that cherry-picks these Batch add Contacts to Companies REST API docs onto the 8.0 branch: #673 It reproduces the approved content from this PR onto 8.0 (one file, +167 lines) and applied cleanly with no conflicts. |
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions and Vale warnings.
| The ``results`` entry properties | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
| The ``results`` entry properties | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| The ``results`` entry properties | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
Applied as written in 992d0c8. The heading is now "The results entry properties", and its underline matches the title length. An earlier commit had reverted this underline fix, which is why it still looked unaddressed.
| The ``summary`` object properties | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
| The ``summary`` object properties | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| The ``summary`` object properties | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
Applied as written in 992d0c8. The heading is now "The summary object properties", and its underline matches the title length.
| Per-pair ``status`` values | ||
| ~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
| Per-pair ``status`` values | |
| ~~~~~~~~~~~~~~~~~~~~~~ | |
| Per-pair ``status`` values | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
Applied as written in 992d0c8. The heading is now "Per-pair status values", and its underline matches the title length. I also added a .. _per-pair status values: label above it, so the status row can link to this section.
| - ``An unexpected error occurred`` | ||
| - Mautic couldn't process the pair | ||
|
|
||
| Mautic records each new assignment made through this endpoint in the Contact's Company change log. It doesn't add a log entry when the Contact already belongs to the Company, and a pair for an existing link still returns a ``200`` status in its result. The 'Add Contact to Company' endpoint also writes to this log for each new assignment. Both endpoints record a ``type`` of ``api`` and an action of 'Lead added to the company, <company name>', and differ only in the event name: this endpoint records 'API batch assignment', while the 'Add Contact to Company' endpoint records 'API assignment'. |
There was a problem hiding this comment.
| Mautic records each new assignment made through this endpoint in the Contact's Company change log. It doesn't add a log entry when the Contact already belongs to the Company, and a pair for an existing link still returns a ``200`` status in its result. The 'Add Contact to Company' endpoint also writes to this log for each new assignment. Both endpoints record a ``type`` of ``api`` and an action of 'Lead added to the company, <company name>', and differ only in the event name: this endpoint records 'API batch assignment', while the 'Add Contact to Company' endpoint records 'API assignment'. | |
| Mautic records each new assignment made through this endpoint in the Contact's Company change log. It doesn't add a log entry when the Contact already belongs to the Company, and a pair for an existing link still returns a ``200`` status in its result. The 'Add Contact to Company' endpoint also writes to this log for each new assignment. Both endpoints record a ``type`` of ``api`` and an action of 'Lead added to the company, <company name>', and differ only in the event name. This endpoint records 'API batch assignment', while the 'Add Contact to Company' endpoint records 'API assignment'. |
There was a problem hiding this comment.
Applied in 992d0c8, using your wording and sentence split. I checked the facts against the source PR: the api type, the action text, both event names, and the unchanged 200 for an existing link.
I made one small change. The stored action value is now formatted as code: Lead added to the company, {company name}. Vale flagged Lead and company inside that string, but Mautic generates it, so the wording can't change. The placeholder uses curly braces, following the style guide.
| - ID of the Company in the pair | ||
| * - ``status`` | ||
| - integer | ||
| - Per-pair status code. See the status values below. |
There was a problem hiding this comment.
There are a couple of things here:
- Link the 'status values' because 'below' isn't clear. The 'below' isn't directly the status values.
- Replace 'below' with 'section', and the period for consistency.
| - Per-pair status code. See the status values below. | |
| - Per-pair status code. See the status values section |
There was a problem hiding this comment.
Done in 992d0c8, with the link added. The row now reads: Per-pair status code. See the :ref:status values section <per-pair status values>
It links to the "Per-pair status values" section instead of saying "below". There's no trailing period, which matches the other description cells. The link resolves in a local Sphinx build.
|
In reply to this discussion Thanks, @adiati98. I'm applying your five inline suggestions and fixing the Vale warnings now, and I'll reply in each thread when the update is on the branch. |
…tion Fix h5 heading underlines, link the per-pair status values section, and apply the reviewer's change-log paragraph with the action value as a literal to clear Vale FeatureList findings.
|
In reply to this discussion @adiati98 I've applied all five inline suggestions and fixed the Vale warnings in commit The 8.0 version of this page (PR #673) still has the old 'See the status values below.' wording and change-log sentence. I can make the same edits there if you'd like. GitHub wouldn't let me re-request your review, so please take another look when you have a moment. Docs PR: #593 |
Open in Promptless
Adds a "Batch add Contacts to Companies" section to the Companies REST API reference for the new
POST /companies/batch/addcontactsendpoint (mautic/mautic PR #16512). Covers theassignmentsrequest body, per-pair results, thesummaryobject, per-pair status values, the batch size limit, and change-log behavior. Targets the 7.3 docs branch (source base 7.x).Latest revision (review feedback from @adiati98)
The ``results`` entry properties,The ``summary`` object properties, andPer-pair ``status`` valuesheading suggestions. The underlines now match the title lengths.statusrow now links to the per-pair status values section instead of saying "below", and has no trailing period, like the other description cells. To make the link work, I added a.. _per-pair status values:label above that section.LOG_TYPE = 'api', theLead added to the company,prefix, and theAPI batch assignmentandAPI assignmentevent names). I formatted the stored action value as a literal,Lead added to the company, {company name}, and used the style guide's curly-brace placeholder. Without that, Vale flaggedLeadandcompany(Mautic.FeatureList) inside the system string, which can't be reworded.Validation
:ref:to the status values section resolves.Trigger Events