# Knock Actions

## Approve a knock request

> Approves a pending knock request and creates the corresponding membership

```json
{"openapi":"3.0.3","info":{"title":"Memberships API","version":"1.0.0"},"servers":[{"url":"https://api.example.com","description":"Production server"},{"url":"https://staging-api.example.com","description":"Staging server"}],"paths":{"/memberships/knocks/{knockId}/approve":{"post":{"tags":["Knock Actions"],"summary":"Approve a knock request","description":"Approves a pending knock request and creates the corresponding membership","parameters":[{"name":"knockId","in":"path","required":true,"description":"Unique ID of the knock to approve","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"approvalMessage":{"type":"string","description":"Optional message for the approval"},"customRole":{"type":"string","description":"Override the requested role (optional)"},"customPermissions":{"type":"array","items":{"type":"string"},"description":"Override the requested permissions (optional)"}}}}}},"responses":{"200":{"description":"Knock approved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the action was successful"},"message":{"type":"string","description":"Action result message"},"knock":{"type":"object","description":"Updated knock request information","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["member","team","collective"]},"status":{"type":"string","enum":["approved","rejected"]},"approvalMessage":{"type":"string","description":"Message from the approver (if applicable)"},"rejectionReason":{"type":"string","description":"Reason for rejection (if applicable)"},"rejectionMessage":{"type":"string","description":"Message from the rejector (if applicable)"},"updatedAt":{"type":"string","format":"date-time","description":"Date and time of last update"},"approvedAt":{"type":"string","format":"date-time","description":"Date and time when the knock request was approved (if applicable)"},"rejectedAt":{"type":"string","format":"date-time","description":"Date and time when the knock request was rejected (if applicable)"}}},"membership":{"type":"object","description":"Created membership information (only when approved)","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["organization","team","collective"]},"teamId":{"type":"string","format":"uuid","description":"Team ID (when type is team)"},"collectiveId":{"type":"string","format":"uuid","description":"Collective ID (when type is collective)"},"userId":{"type":"string","format":"uuid"}}}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"Unique error code"},"message":{"type":"string","description":"Descriptive error message"},"details":{"type":"array","description":"Additional error details","items":{"type":"object","properties":{"field":{"type":"string","description":"Field that caused the error"},"message":{"type":"string","description":"Specific error message for the field"}}}},"timestamp":{"type":"string","format":"date-time","description":"Error timestamp"},"traceId":{"type":"string","description":"Trace ID for debugging"}}}}}}}}}}}}}
```

## Reject a knock request

> Rejects a pending knock request

```json
{"openapi":"3.0.3","info":{"title":"Memberships API","version":"1.0.0"},"servers":[{"url":"https://api.example.com","description":"Production server"},{"url":"https://staging-api.example.com","description":"Staging server"}],"paths":{"/memberships/knocks/{knockId}/reject":{"post":{"tags":["Knock Actions"],"summary":"Reject a knock request","description":"Rejects a pending knock request","parameters":[{"name":"knockId","in":"path","required":true,"description":"Unique ID of the knock to reject","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"rejectionReason":{"type":"string","description":"Reason for rejecting the knock request"},"rejectionMessage":{"type":"string","description":"Optional message for the rejection"}}}}}},"responses":{"200":{"description":"Knock rejected successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the action was successful"},"message":{"type":"string","description":"Action result message"},"knock":{"type":"object","description":"Updated knock request information","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["member","team","collective"]},"status":{"type":"string","enum":["approved","rejected"]},"approvalMessage":{"type":"string","description":"Message from the approver (if applicable)"},"rejectionReason":{"type":"string","description":"Reason for rejection (if applicable)"},"rejectionMessage":{"type":"string","description":"Message from the rejector (if applicable)"},"updatedAt":{"type":"string","format":"date-time","description":"Date and time of last update"},"approvedAt":{"type":"string","format":"date-time","description":"Date and time when the knock request was approved (if applicable)"},"rejectedAt":{"type":"string","format":"date-time","description":"Date and time when the knock request was rejected (if applicable)"}}},"membership":{"type":"object","description":"Created membership information (only when approved)","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["organization","team","collective"]},"teamId":{"type":"string","format":"uuid","description":"Team ID (when type is team)"},"collectiveId":{"type":"string","format":"uuid","description":"Collective ID (when type is collective)"},"userId":{"type":"string","format":"uuid"}}}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"Unique error code"},"message":{"type":"string","description":"Descriptive error message"},"details":{"type":"array","description":"Additional error details","items":{"type":"object","properties":{"field":{"type":"string","description":"Field that caused the error"},"message":{"type":"string","description":"Specific error message for the field"}}}},"timestamp":{"type":"string","format":"date-time","description":"Error timestamp"},"traceId":{"type":"string","description":"Trace ID for debugging"}}}}}}}}}}}}}
```
